No such thing as a small change | |
PerlMonks |
Re^2: capture optional textby haukex (Archbishop) |
on May 18, 2017 at 13:55 UTC ( [id://1190536]=note: print w/replies, xml ) | Need Help?? |
while (chomp(my $line = <DATA>)) { This won't work if the final line doesn't end on a newline, as chomp returns the number of newlines it removed. Better to use the traditional while (<DATA>) { chomp; ... or while (my $line = <DATA>) { chomp($line); ... Update: Plus, even with a trailing newline, the code generates a warning, since after the final line, the loop condition is executed one more time, and <DATA> will return undef and chomp(my $line = undef) causes a warning.
In Section
Seekers of Perl Wisdom
|
|