2009/10/23

perl note part1

Perl does not have Boolean type true/false

Chomp chops new line, but chop chops the last char

Below does not work in php ($sum UNDEF), but works in perl (unless warning/strict turn on)

$n=1;

while($n<10){

$sum += $n++;

}

print $sum;

qw shortcut

qw /fred barney betty Wilma dino/ == (“fred”, “barney” …)

@array = 6..9

Push/pop operators do things to the end of an array, but shift/unshift do things to the begin of an array

for (1..9){ print;} == for (1..9) {print $_;}

sort/reverse functions does not change the array itself, but return a sorted/reversed array

No comments:

Post a Comment