http://www.perlmonks.org?node_id=749327


in reply to Reading a text file collapsing line continuations

I can repeat your issue with my Linux box (and get good behavior w/ AS 5.8.8 under Windows). Based upon what I see in my debugger, you are having a scoping issue. Essentially, every iteration of your while loop reinitializes $line as per your my statement. My guess is they modified the scoping behavior in 5.10.0, which fixes this particular issue. You can avoid the problem with:

#!/usr/bin/perl -w use strict; use warnings; my $line; while (defined($line = <DATA>) ) { chomp $line; # line 7 if ($line =~ s/\\$//) # line 8 { $line .= <DATA>; redo unless eof(DATA); } print "LINE: '$line'\n"; } __DATA__ 1 1 2 2 3 3 4 4 \ 4 4 \ 4 4 5 5

Update:Regarding your comment

I would expect that the while loop wouldn't run if there was an undefined line - so I'm unclear on why the chomp is giving the uninitialized variable warning.
you should check out the documentation to see why the original developer used a redo in place of a next.