[oak perl] my operator question
Zed Lopez
zed.lopez at gmail.com
Tue Mar 8 10:00:54 PST 2005
On Tue, 8 Mar 2005 09:52:29 -0800, Zed Lopez <zed.lopez at gmail.com> wrote:
> You shouldn't do end-of-line modifiers (if, unless, while, for) with
> my statement. You're using a new, undef'd $total each time through the
> for loop. And it's undef after the loop, too. It seems to be the
> equivalent of:
>
> my @numbers = qw(1 4 6);
> my $total;
> for (@numbers) {
> my $total;
> $total += $_;
> }
> print $total;
Oops. I contradicted myself there -- if it's equivalent to the latter,
it's not the case that you're using a new, undef'd $total each time
through the for loop. I really don't know what Perl might be doing
inside that for loop; I only know the external behavior.
Anyone have a clue what's _really_ happening?
More information about the Oakland
mailing list