Perl Gripes

July 14, 2005

Many many years ago, I used to write a lot of perl code. Then I discovered PHP and thankfully I didn't have to use perl anymore. As a result I have forgotten many of the perl tricks that I learnt. Now you might say that is good news, unfortunately occaisionally I find myself occaisionally having to read/write a perl script.

One of the gripes is that a language that is so good at string handling does not have a trim() function like what you find in perl. You need two lines of forgettable perl code to achieve the same result. (chomp is only good for removing the trailing newline)

$hash =~ s/^\s+//; $hash =~ s/\s+$//;

Another gripe is the fact that perl does not have a readfile() or fpassthru() method, the likes of which you find in PHP. So you need quite a few more lines of code for the same result.

open(INFILE, $file); while () { print $_; } close(INFILE);

It get's worse if you care about file locking.

Posted by raditha at July 14, 2005 6:59 AM
Your Ad Here

 

Jabber  |  Linux  |  mySQL  |  PHP  |  Java  |  Site Map  |  Wiki

Downloads  |  About  |  Links  |  Contact  |  Home

 

Copyright © Raditha Dissanayake 2003 - 2007

Terms of Use  |  Privacy

 

 

July 2005
Sun Mon Tue Wed Thu Fri Sat
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31