Ted Ashton writes:
: Thus it was written in the epistle of Michael G Schwern,
: > On Sun, Jan 20, 2002 at 10:58:34PM -0800, Larry Wall wrote:
: > > : while( my $line = <FILE> ) {
: > > : ...
: > > : }
: > >
: > > That still works fine--it's just that $line lives on after the while.
: >
: > This creeping lexical leakage bothers me. While it might make the
: > language simpler, the proliferation of left-over lexicals seems
: > sloppy.
:
: . . . if not to say downright ugly. The boolean of an if or a while is more a
: part of the "inner stuff" than the "outer".
It doesn't seem that way to me.
: What's the chance that it could be considered so?
In most other languages, you wouldn't even have the opportunity to put
a declaration into the conditional. You'd have to say something like:
my $line = <$in>;
if $line ne "" { ... }
Since
if my $line = <$in> { ... }
is Perl shorthand for those two lines, I don't see how one can say that
the variable is more related to the inside than the outside of the block.
One can claim that the code after the C<if> may not be interested in
C<$line>, but the same is true of the block itself! The conditional
only decides whether the block runs. It's not part of the block.
Larry