Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^3: Reading a text file collapsing line continuations

by kennethk (Monsignor)
on Mar 09, 2009 at 18:51 UTC ( #749387=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Reading a text file collapsing line continuations
in thread Reading a text file collapsing line continuations

That my Linux box (v5.8.8 built for x86_64-linux-gnu-thread-multi under Ubuntu) replicates the issue and my Windows box (v5.8.9 built for MSWin32-x86-multi-thread, I forgot I upgraded) does not implies something differs between the implementations. Running the Linux variety through my debugger shows $line to be undef on line 7 on the continuation case, whereas it maintains continuity under AS. Since we are dealing with a variable which is scoped at the loop, I was reading it as the variable was getting a new instance upon redo even though the my was not being re-evaluated. This is supported by the following code, which prints an infinite series of 1's on my Windows box and prints one 1 and then an infinite series of "Use of uninitialized value in print at fluff.pl line 6, <DATA> line 1." on my Linux box:

#!/usr/bin/perl -w use strict; use warnings; while (defined(my $line = <DATA>) ) { print $line; redo; } __DATA__ 1

Update: Better example code (I think). Prints 210 under Windows and 2 under Linux:

#!/usr/bin/perl use strict; use warnings; my $j = 2; while ( my $i = $j ) { print $i if defined $i; last unless $i--; redo; }

Update 2: Filed a bug report, id [perl #63752]


Comment on Re^3: Reading a text file collapsing line continuations
Select or Download Code
Re^4: Reading a text file collapsing line continuations
by CountZero (Bishop) on Mar 09, 2009 at 19:28 UTC
    It is quite frightening that there are such fundamental differences between Linux and Windows implementations. I would rate that as a bug.

    CountZero

    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

Re^4: Reading a text file collapsing line continuations
by kennethk (Monsignor) on Mar 12, 2009 at 15:57 UTC
    Received a reply on the bug report. The change in behavior between 5.8.8 and 5.10.0 represents "an intended change of behaviour (a bugfix)". The fact that the AS distribution behaves well reflects non-standard patching implemented by AS (Change 24412). Incident is closed, though it seems to me like this patch also needs inclusion in the next distro of 5.8.x.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://749387]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (7)
As of 2014-09-17 21:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (100 votes), past polls