Anti-nuisance lawsuit warning: The purpose of these notes is to remind me, Zoegond, of stuff or to help me work stuff out. They may contain mistakes.

Quick

  • ($a, $b....) = unpack("A2A7...", $packed)
  • push( array, list )

Monday, March 1, 2010

Perl for loops

for($n = 0; $n<10; ++$n) {
}
print $n;

will print 10, not 9. $n is incremented the last time control returns to the for - ++$n happens before the $n<10 check, because the loop control statement means

1. If this is the first iteration, $n = 0
2. if $n < 10, execute the loop body...
3. .. then ++$n
4. goto 1

Followers

Blog Archive