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

Ok I looked at it deeper and it seems that the entire file is being read in as one line ( ignoring the /n ) how do i fix that? ANd think you for the help already :)

Replies are listed 'Best First'.
Re: Re: Re: Cannot read in multiple lines
by Enlil (Parson) on Nov 04, 2002 at 00:09 UTC
    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

      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