Monday, August 10, 2009

Rakudo to the rescue!

I've had a lot of Rakudo-frustration due to its slowness this week, so it was nice to find an application where Rakudo was well-suited already. I just wrote a script for checking the validity of one of my software releases... more than fifty files uploaded (lots of different configurations), each encoded with its own password. It was easy enough to write a Perl 6 script to scan the batch file used to create the release to get the filenames and passwords, then download each file using curl and use unzip to test its validity. And the download times dominant the running time of the script, so Perl 5 wouldn't have been appreciably faster.

qqx is very nice for running external programs and capturing the results. I'm still in love with using when in for loops -- I realize basically the same thing could be done even in Perl 5.8 using if, but somehow when just feels right to me. (Oh wait -- the difference is that after when triggers, it goes to the next iteration of the loop, right? Maybe that's why it seems so nice.)

The only real trip-up I had writing this script was once again forgetting that whitespace is ignored in Perl 6 regexs. I had several minutes of panic, thinking that somehow I wasn't getting the correct result from qqx, or that something special needed to be done to match against strings with embedded newlines. Then I realized I just needed to add :s to both regexes. I understand the logic of doing it that way, but I know I will trip up on that more times in the future...



    That's with the identifying bits stripped out, but it should give the idea...