Updated: September 16th, 2012
StackOverflow is an amazing site for coding questions. It was created by Joel Spolsky of joelonsoftware.com, Jeff Atwood of codinghorror.com, and some other incredibly smart guys who truly care about user experience. I have been a total fan of SO since it went mainstream and it's now a borderline addiction (you can see my StackOverflow badge on the right sidebar).
Update 6/21/09: This server is currently under very heavy load (10-200), even with caching plugins enabled. Please bear with me as I try to resolve the situation.
Feel free to bookmark this page and return to it later when the fires have been put out.
Update 06/21/09: I think I've got the situation …
Updated: October 6th, 2009
No matter what programming language you use, there comes a time when you need to search for a file somewhere on the file system. Here, I want to talk about accomplishing this task in Perl. There are many ways of doing so, most of them boring, but I want to discuss the fun and elegant way – using File::Find::Rule.
Let me briefly discuss some of the other methods first.
Using glob() (or <>, TODO verify) you can find files in a single directory, using only the limited shell wildcard support. For example,
my @files = glob("tmp*");
Updated: June 9th, 2009
While writing a 1093985th Perl script the other day I was facing the following dilemma:
- Let’s say there is a local library, called TheUberLib.pm. It is so uber that most of my scripts, located all over the machine, include it.
- Now, let’s also say that there’s an even more uberly important binary called run_me_now_or_you_will_die but the only way to find it is by using a relative path to the aforementioned TheUberLib.pm, for example ../bin (RELATIVE TO TheUberLib.pm).
- I don’t want to hardcode the path to run_me_now_or_you_will_die because it can be different on multiple machines and the code wouldn’t be robust enough – all I know is that the path is relative to an included library.
Updated: October 6th, 2009
I'm sure most Perl coders have to face this annoying problem at one point or another: how do you consistently get the return value out of a system call, be at executed via backticks or system()? Backticks return the output of the program with no error code in sight, while system() returns the error code but prints the output instead of putting it into a variable.
The best solution I could find to this problem to date was posted at http://www.perlmonks.org/?node_id=19119 and involved opening a piped filehandle. It worked quite well but always felt like a hack (which it was). Having used the new Perl 5.10 for a few months, I was shocked today to find this new variable that …