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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Reading a text file collapsing line continuations
by CountZero (Bishop) on Mar 09, 2009 at 17:59 UTC | |
by kennethk (Abbot) on Mar 09, 2009 at 18:51 UTC | |
by CountZero (Bishop) on Mar 09, 2009 at 19:28 UTC | |
by kennethk (Abbot) on Mar 12, 2009 at 15:57 UTC | |
|
Re^2: Reading a text file collapsing line continuations
by skx (Parson) on Mar 09, 2009 at 17:58 UTC |