Monday, April 27, 2009

Perl

I have just been on a two day training course which introduces the basics of Perl. I've heard good things about it before, and I get paid for doing it, so I said why not. Turns out, its actually incredibly useful. They have tried to make it as OS independent as possible (eg: chomp() strips off the appropriate end line characters whether you are on Windows or Linux, etc).

Also, the regular expressions engine make it very nice to parse text. I also discovered a regular expression checker tool, which has a nice GUI that can help you come up with regular expressions by showing what they match. You can provide a regex, and a input string. The variables in the lower pane actually show you what your regex matches. Very handy, and very useful.

I was surprised how quickly I could do some useful things, and in only two or three lines. I'm not the best programmer in the world, and it takes a notoriously long time for me to pick up on certain constructs, but I found the basics were very easy to pick up. Perl likes to pack a lot of functionality into a couple of short lines of code. It can look cryptic, but once you understand it, it's not so bad.

Having said that, it seems like if you don't use it regularly, you'll quickly forget certain elements. Some of the ideas/syntax for such things as hash tables, sort functions, $_, file I/O, can easily be forgotten if you don't use them regularly I'd say.

No comments: