in reply to What will this print?
I liked this handy little debugging aid from mjd's Perl Hardware Store talk:
@x = (0, 'one', ' ', 3); $"=')('; print "(@x)";
And here's one that looks kind of obvious, but has a subtlety or two:
my $i = 0; sub inc { ++$i } foreach (1..10) { print "$_\n" if(inc == 3 .. inc == 8) }
Update:
And here's one that just bit me. It took a few minutes before I realised what was going on:
my $animal = 'pig'; foreach $animal ('cat', 'dog', 'horse') { last if $animal eq 'dog'; } print "$animal\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: What will this print?
by Aristotle (Chancellor) on Mar 31, 2003 at 09:23 UTC |