in reply to Re: •Re: "for" surprise
in thread "for" surprise
Relying on the fact that the loop iterator has a defined value after leaving the loop is bad style in many languages, as many languages explicitly state the value of the loop iterator as undefined.
Personally, I prefer to create loop iterators that are scoped only to the loop block, as that completely avoids the issue:
for my $i (1..67) { ... };
That way, $i can't be used outside the loop, and I consider that a good thing. But why are you using a loop over a fixed range instead of a loop from 1 to $end anyway?
perl -MHTTP::Daemon -MHTTP::Response -MLWP::Simple -e ' ; # The $d = new HTTP::Daemon and fork and getprint $d->url and exit;#spider ($c = $d->accept())->get_request(); $c->send_response( new #in the HTTP::Response(200,$_,$_,qq(Just another Perl hacker\n))); ' # web
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: •Re: "for" surprise
by fletcher_the_dog (Friar) on Nov 21, 2003 at 20:26 UTC | |
by etcshadow (Priest) on Nov 22, 2003 at 03:42 UTC | |
by Abigail-II (Bishop) on Nov 21, 2003 at 21:24 UTC |