in reply to Extracting the last desired block of text from a server eMail file

One of my favorite IO:: modules is IO::All which wraps up a bunch of different IO operations into a surprisingly easy to use module.

One of these operations allows you to read the file backwards (using File::ReadBackwards):
# not tested of course my @message; my $io = io('mail_file')->backwards->chomp; while (my $line = $io->getline) { unshift @message, $line; last if($line =~ m/$message_start_pattern/); } # @message now contains all lines of the # last message in correct order for(@message){ last if($_ eq "Content-Type: text/html;"); print "$_\n"; }
You of course could use File::ReadBackwards by itself

--b
  • Comment on Re: Extracting the last desired block of text from a server eMail file
  • Download Code

Replies are listed 'Best First'.
Re^2: Extracting the last desired block of text from a server eMail file
by hackermike (Novice) on Sep 17, 2004 at 05:46 UTC
    Thx for your reply! My ISP does not have the File::ReadBackwards): Installed. Tried, but do not have the permisssions to copy it in the perl folder. I have hacked the code every which way, even resorted to
    open(FILE,"$filename"); @lines = <FILE>; close(FILE); @lines = reverse sort(@lines);
    preceeding my origninal code. Oddly, while some text is printed to the output filename2, I is weirdly done, prints some lines in the correct order but does not strickly follow the test for split directive. Any ideas? thx mike @lines = reverse sort(@lines);