Stepped off the beaten path, veered too far off the shoulder...SOMETHING. Got an announcement today that one of my coworkers wife just had their baby(BTW, Contrats Mike and wife!). Usually this kind of announcement is followed up by me with "Aww, how cute.. Good luck sleeping! I don't envy you!".
Today was different. Today I looked at the picture of the baby, and thought "Man, I'm jealous.". That's an interesting reaction for me, because it made me remember a time when babies and family and all that were exactly what I wanted. I've not felt that for a loooong time. It was nice.. It really makes me feel like I lost track.
Moving on past the sappy stuff; I've found something fun to play with lately. It's called "Let's see how many scripts I would usually write in Perl that I can write in Python instead.". I'm up to four now, and I'm massively impressed with what I've been exposed to. I'm going to give a simple "For instance".
The other day at the office I was tasked with creating a crapload of Redirect rules for Apache. All similar format/results, but different enough that one common RegExp with RedirectMatch wouldn't have done the trick. The list of the source and destination paths were sent to me in an excel file, which I then converted to csv. Rather than copy and paste 50+ of these into the Apache conf and hand tailoring them, I decided to write a script to parse it and spit out the rules I needed.
In python, it was as simple as using an example from here: http://docs.python.org/lib/csv-examples.html
To my knowledge Perl doesn't have any CSV parsing modules in the code distribution, which means CPAN fun will ensue. To get the mega list of installed Perl modules on my host, I have to write a Perl script (no root access).
Here's the script:
#!/usr/bin/perl
use ExtUtils::Installed;
print "$_
" for ExtUtils::Installed->new()->modules;
Run that and grep the output for anything csv.
# ./list_mods.pl | grep -i csv
#
Yup, I was right.. At least as of 5.8.6 (slightly old dist) there's no CSV module installed. So now, let's install one (of the 232 results I got back in a quick search):
# perl -MCPAN -e 'install Text::CSV'
I still have to write the code! I've wasted 10 minutes! Ironically enough, 10 minutes is what it took me to modify a common example of CSV parsing in python and to top it off, the python code is easier on the eyes.
I still LOVE my Perl, and if I'm ever in a pinch and really _need_ to have a script done, like now, I'll probably run to it, or the shell first.