Tuesday, February 22, 2005

Learning Perl

5 days after joining my job, I am learning Perl during my free time. Actually, it all started when I noticed that Perl is used here on the server-side and as I like web programming I thought of learning Perl. Perl is very much like PHP but its internal functions are very basic & elementary, so you'll need a lot of practice to implement them. The toughest part of Perl is the pattern matching, there are a hell lot of options & methods to use, so generally its not possible to remember all.
In PHP we can use the function str_replace() to replace an occurence, but for Perl the code goes something like this:
$value=~tr/+/ /; # replace \+ with space where value is the original string and we
#intend to replace '+' with a blank space

The PHP equivalent:
span style="color:#333333;">$value="This+is+a+string";
$value=str_replace("+"," ",$value); //so simple

Still Perl is very interesting, Next time I'll tell you about database access using Perl!

No comments: