Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re: Perl ignores CarriageReturn during fileparsing. Why?

by Athanasius (Chancellor)
on Jun 13, 2013 at 12:08 UTC ( #1038729=note: print w/replies, xml ) Need Help??

in reply to Perl ignores CarriageReturn during fileparsing. Why?

The input record separator is stored in the special Perl variable $/. It is newline (i.e., \n, not “carriage return”, which is \r) by default.

Have your “far away” changes altered the value of $/?

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

Replies are listed 'Best First'.
Re^2: Perl ignores CarriageReturn during fileparsing. Why?
by hoppfrosch (Scribe) on Jun 13, 2013 at 12:21 UTC
    You are my god for today - Wrong value within $/ (INPUT_RECORD_SEPARATOR) was the culprit; resetting it to '\n' solves my problem.
    I assumed there has to be a special variable for this - but couldn't find it ...
    Any change I made must have altered the value of $/ - have to find out which.
      Normally the input record separator should only be changed in the scope for which you need to change it
      # code "borrowed" from node 1952 :-) { local $/ = undef; open FILE, "myfile" or die "Couldn't open file: $!"; $string = <FILE>; close FILE; } # $/ reverts back to default here...
      If you spot any bugs in my solutions, it's because I've deliberately left them in as an exercise for the reader! :-)
        The change happened by accident and not intentional - until now I wasn't able to locate the change within my own code. Perhaps it happens somewhere in an external perl module ....

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1038729]
and John Coltrane plays...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (2)
As of 2018-04-22 10:29 GMT
Find Nodes?
    Voting Booth?