http://www.perlmonks.org?node_id=1023248


in reply to Re^2: How do I use the "File::ReadBackwards" and open in "Unicode text, UTF-32, little-endian" mode
in thread How do I use the "File::ReadBackwards" and open in "Unicode text, UTF-32, little-endian" mode

I have found a simple solution for my particular case, as I know that I only want to match certain strings from the log file and none of the match strings will be none ASCII characters.

I can use the ReadBackwards to read the line in then strip out none ASCII and null characters.

my $ERRORLINES_IN = File::ReadBackwards->new($logfile) or die "$logfil +e : $!\n"; while (defined($logline = $ERRORLINES_IN->readline)) { $logline =~ s/[^[:ascii:]]//g; $logline =~ s/\0//g;

It's not a perfect solution but it works for my case.

  • Comment on Re^3: How do I use the "File::ReadBackwards" and open in "Unicode text, UTF-32, little-endian" mode
  • Download Code

Replies are listed 'Best First'.
Re^4: How do I use the "File::ReadBackwards" and open in "Unicode text, UTF-32, little-endian" mode
by Anonymous Monk on Apr 25, 2018 at 22:59 UTC
    File::ReadBackwards wouldn't work for me on Windows until I added two extra arguments:
    File::ReadBackwards->new($file,"\015\012",false);
    After that it started working as expected, which is odd, because it appears to set that as the default for Windows in the .pm.