I like Perl

There’s only one way to learn a language, practise it!. For sure one thing it’s to know syntax and a distinct thing it’s know logical beside all that stuff…An example, I’ve review one of my first perl scripts and there I found something like this:

if ( $zone == 1) {
$zone = “01” ;
}

if ( $zone == 2) {
$zone = “02” ;

and son on until 9 was converted to 09. As soon as I show code I decide to improve it, I know what I wanna do but I don’t know how, then I remenber something like join.

Few minutes later here you got it:

if ( $zone =~/^\d$/ ) {
$new_zone = join ”, 0,$zone;
}

I specially like regular expressions ’cause they’re very useful, you may use them with perl [perlre: stands for perl+re where re means regular expression], with Vi, inside pure bash shell, by using sed or by commands like grep with -E flag…

Post a Comment

Your email is never shared. Required fields are marked *

*
*