Thursday, December 11, 2008

Why I love Perl

I'm a Perl newbie, only started using Perl 2 weeks or so ago. And I'm already falling in love with it!
I love how fast I can get work done with Perl.
In other languages you find yourself working on things before you even started working on the problem on hand.
Let me clarify, in Perl, you simply, open a file and pass its content to an array like this:
 
open(INFILE, $inFile) or die("Error: Can't open file!");
@lines = <INFILE>;
$inFile is assumed to have the name of file you want to open, and @lines is the array that'll store the file content.
People familar with scripting language might be wondering why I'm making a fuzz, but the fact is, I'm also new to scripting languages. Things like this are a revelation to me!
Another reason is, I had an array of lines of ASCII and I wanted to reverse the lines, in other languages you had to write a loop to do that, simple, right? In Perl it is even simpler, all you have to do is this:

@revGrd = reverse @grid;

And the final reason is converting to binary, it is as simple as pack.

No comments: