in reply to Re: Re: Cannot read in multiple lines
in thread Cannot read in multiple lines

I would guess that at some point you assigned $\ $/ a new value, or perhaps undefined it. If you need this you should put it in a block and localize the assignment, like so:
{ local $\ = undef; $_ = <SOME_FILE>; }
{ local $/ = undef; $_ = <SOME_FILE>; }
This will keep $\ $/ from continuing to be redefined as whatever you might have set it as (and set back to the default newline), once you have left the block.

Update: As dingus pointed out. I did mean $/ as opposed to $\, which is the output record separator. So I have changed all instances in the code and response above. Thanks dingus

-enlil

Replies are listed 'Best First'.
Re: Re: Re: Re: Cannot read in multiple lines
by dingus (Friar) on Nov 04, 2002 at 13:06 UTC
    Enlil quoth
    I would guess that at some point you assigned $\ a new value, or perhaps undefined it. If you need this you should put it in a block and localize the assignment, like so: ...

    Surely you mean $/ not $\. $/ is INPUT_RECORD_SEPARATOR while $\ is OUTPUT_RECORD_SEPARATOR according to perlvar

    Other than that - it looks like excellent advice.

    One other possibility is that the input file has been produced by a computer with different line characteristsics. E.g. A windows PC reading a file creted by a Unix program will also do precisely what you are experiencing. In which case setting $/ to be the very specific chr(13) woule be a good idea.

    Dingus