in reply to Problem using File::ReadBackwards

vxp,

I'd say you might have a problem with your datafile in that it contains something that you are not expecting/handling.

Try removing lines or chunks of lines from the data file until your problem goes away. When it begins to work, add the lines back in until it breaks again to detemine the offending line(s).

Alternatively, construct a bogus and properly formatted file that *must* work, and then begin inserting lines that could cause it to break.


Where do you want *them* to go today?

Replies are listed 'Best First'.
Re^2: Problem using File::ReadBackwards
by vxp (Pilgrim) on Jul 10, 2007 at 17:49 UTC

    You all were right.

    It turned out the log file had empty lines in it, for whatever reason our developers decided to stick them in there.

    I easily solved it by simply doing:

    next if $log_line =~ /^$/;
    prior to
    last if $log_line lt $earliest;
      ysth is dead right. Why check for the one case which you know doesn't work and exclude it? It would be safer (in case your designers do something else weird) to look for the condition that satisfies your requirements.

      I'll even save you the typing:
      while ( defined( my $log_line = $bw->readline() ) ) { my ($logTime) = ($log_line =~ /^(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{ +2}).*ProcessHTTPRequestImpl/); if ($logTime){ last if $logTime lt $earliest; print $log_line; } }
      Please don't use:
      next if $log_line =~ /^$/;
      ... I shudder just thinking about it :-)