in reply to Re: A refactoring trap
in thread A refactoring trap
Dispite that many has pointed out that
are identical, your first remark is true. The problem lies elsewhere:while (my $line = <DATA>) { ... } while (defined (my $line = <DATA>)) { ... }
doesn't localize $_ and thus leaves $_ undefined after the loop.while (<DATA>) { ... }
doesn't suffer from this as it doesn't touch $_.while (my $line = <DATA>) { ... }
If put in a subroutine this innocent little bug cause a serious headache while trying to find out why $_ all of a sudden is undefined.
ihb
See perltoc if you don't know which perldoc to read!
|
---|
In Section
Meditations