The Penalty Box
Five minutes for attempted world domination
Down with OPP?
February 21, 2012 at 08:02 PM | categories: Coding, Tech | View CommentsA lot of people rag on Perl as a language. Indeed, I can agree with some of their points. It's not great as a page serving language, despite a decent framework like Catalyst. The syntax lends to awful looking code. Figuring out what it does can take just as long as rewriting it yourself. However, I still think it's a good language to do system level stuff: parsing, deployment and other assorted back end stuff. It's pretty fast (in the world of scripting languages at least, although there are some crazy things being done in Python to get it to the speed of compiled C with JIT compiling), there is good library support and it's been around forever so it's pretty stable.
The downside usually lies in reading code that is not your own (Other People's Perl). I was trying to use a Perl library recently that interacted with Amazon's S3 storage, but it wasn't doing quite what I wanted to do. I then came across this little tidbit that made me want to punch the developer in the face.
my $cmd = qq[curl $curl_options $aws $header --request $verb $content --location @{[cq($url)]}];
Anyone want to hazard a guess? No? Yeah didn't think so, not unless you're one of those crazy Perl guys. It starts off pretty normal. "qq[" is another way of doing the backtick operator, capturing output and assigning it to $cmd. The rest is pretty straightforward too, until you get to the parameter of location. Eventually I figured out that the output of cq was an array of strings. The square brackets annonymizes the array and the @{} syntax derefences the array and joins it with the empty string. This is an example of someone who is trying to be clever with his code when he could have just used a freaking join function!
You down with OPP? Hell no, not me.