home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / xampp / xampp-perl-addon-1.4.9-installer.exe / read_mbox.al < prev    next >
Encoding:
Text File  |  2004-03-29  |  856 b   |  42 lines

  1. # NOTE: Derived from blib\lib\Mail/Util.pm.
  2. # Changes made here will be lost when autosplit is run again.
  3. # See AutoSplit.pm.
  4. package Mail::Util;
  5.  
  6. #line 97 "blib\lib\Mail/Util.pm (autosplit into blib\lib\auto\Mail\Util\read_mbox.al)"
  7. sub read_mbox {
  8.     my $file  = shift;
  9.     my @mail  = ();
  10.     my $mail  = [];
  11.     my $blank = 1;
  12.     local *FH;
  13.     local $_;
  14.  
  15.     open(FH,"< $file") or
  16.     do {
  17.         require Carp;
  18.         Carp::croak("cannot open '$file': $!\n");
  19.     };
  20.  
  21.     while(<FH>) {
  22.     if($blank && /\AFrom .*\d{4}/) {
  23.         push(@mail, $mail) if scalar(@{$mail});
  24.         $mail = [ $_ ];
  25.         $blank = 0;
  26.     }
  27.     else {
  28.         $blank = m#\A\Z#o ? 1 : 0;
  29.         push(@{$mail}, $_);
  30.     }
  31.     }
  32.  
  33.     push(@mail, $mail) if scalar(@{$mail});
  34.  
  35.     close(FH);
  36.  
  37.     return wantarray ? @mail : \@mail;
  38. }
  39.  
  40. # end of Mail::Util::read_mbox
  41. 1;
  42.