[Chicago-talk] my my if nothing
Greg Fast
gdf at speakeasy.net
Wed May 5 14:04:28 CDT 2004
On Wed, 5 May 2004 08:15:59 -0700 (PDT), Jim Thomason <jthomasoniii at yahoo.com> wrote:
> The general case is that this construct can be used
> (among other things) to simulate a static variable if
> you don't want to use a closure.
[...]
> foreach (1..5) {
> my $i = 7 if 0;
> print $i++, "\n";
> }
This is more readable like this:
{ my $x;
sub foo() {
print $x++, "\n";
}
}
foo() for (1..5);
(Doesn't work under mod_perl, btw. But then, why are you doing it
anyway? :)
--
Greg Fast
http://cken.chi.groogroo.com/~gdf/
More information about the Chicago-talk
mailing list