in reply to Counting variable initialization
Try -MO=Deparse to see what perl thinks of your code:
where file 443218.pl contains$ perl -MO=Deparse 443218.pl my(@l) = ('10', '20', '30'); foreach $_ (@l) { my $t += $_; } print $t; 443218.pl syntax OK
$ cat 443218.pl use warnings; use strict; my @l = qw/10 20 30/; my $t += $_ foreach @l; #my $t; #$t += $_ foreach @l; print $t;
the lowliest monk
Update: Added the contents of the file given to -MO=Deparse for clarification.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Counting variable initialization
by ikegami (Patriarch) on Mar 29, 2005 at 18:41 UTC | |
by tlm (Prior) on Mar 29, 2005 at 18:52 UTC | |
|
Re^2: Counting variable initialization
by eric256 (Parson) on Mar 29, 2005 at 19:34 UTC |