[ABE.pm] 'for' statement Q
Ricardo SIGNES
perl.abe at rjbs.manxome.org
Fri Aug 15 10:34:49 PDT 2008
* Walt Mankowski <waltman at pobox.com> [2008-08-15T13:29:57]
> On Fri, Aug 15, 2008 at 01:19:09PM -0400, Faber J. Fedor wrote:
> > But it turns out to work just like a foreach, IOW, it iterates over the
> > list and $_ is assigned $c then $m then $y.
>
> That's because "foreach" and "for" are equivalent.
which means you can also:
for (my $i = 0; $i < 10; $i++) {
say $i;
}
You *can't* however say:
say $i for (my $i = 0; $i < 10; $i++);
for various reasons, including the nature of lexical scope and assignment.
That and I think the parser barfs.
--
rjbs
More information about the ABE-pm
mailing list