Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

No Format
#!/usr/bin/perl
#
#       splits a file containing multiple messages into individual files
#
use strict;

sub splitmail {
        my $infile = shift;
        my $outdir = shift;
        my $count = 0;

        open(INFILE, "< $infile") or die "Can't open $infile: $!\n";

        while(<INFILE>) {
                /^From / and do {
                        close(OUTFILE) if $count;
                        open(OUTFILE, "> $outdir/$count") or die "Can't open $outdir/$count: $!\n";
                        $count++;
                };
                print OUTFILE $_;
        }
        close(OUTFILE);
}

1;

...

CategoryBayes