in reply to Problems with binary data in text documents

If this is on windows are you setting binmode?


-Waswas
  • Comment on Re: Problems with binary data in text documents

Replies are listed 'Best First'.
Re^2: Problems with binary data in text documents
by omadawn (Initiate) on Nov 22, 2004 at 21:39 UTC
    One thing I don't get is that while I seem to still have access to individual lines the $ char in a regex doesn't do what I expect it to.
    open ( $fh, "< $path_to_file"); binmode($fh); my @log = <$fh>; my $line; while ($line = pop @log) { last if ($line =~ /^.*\ -\ line I'm looking for$/); }
    had to become:
    last if ($line =~ /^.*\ -\ line I'm looking for/);
Re^2: Problems with binary data in text documents
by omadawn (Initiate) on Nov 22, 2004 at 21:20 UTC
    perldoc -f binmode ...reading.... I am now! Thanks.

      Some relevant details...

      If DOS/Windows encounters chr(26) in a text file, it considers that the end of the text file. binmode does not treat chr(26) specially. However, \r\n are not converted to \n in binmode. You may want to set $/ to "\015\012".