[LUGOS] maildir to mbox
Gorazd Brumen
gorazd.brumen at fmf.uni-lj.si
Sun Feb 23 14:07:10 CET 2003
Hvala obema za tako hiter odgovor!
Uporabil sem perl skriptico in moram reci, da deluje fantasticno.
Gorazd
On ned, 2003-02-23 at 13:31, Andraz Sraka wrote:
> re
>
> On Sun, 2003-02-23 at 12:47, Gorazd Brumen wrote:
>
> > Kako torej najenostavneje narediti iz maildir mbox format?
>
> ce ti kaj pomaga, ti prilagam eno perl skriptico, ki pocne prav to ..
>
> lp,
> Andraz
>
>
> --
> * Phaedrus wishes he could get a machine that consists of Sparc IO,
> Alpha Processors and sleek design of an SGI
> <pp> And intel prices
> -- Seen on #Linux
> ----
>
> #!/usr/bin/perl
>
> foreach $file (@ARGV) {
> open (TMP, $file) or do {
> print STDERR "Couldn't open $file : $!\n";
> next;
> };
>
> undef $who;
> undef @body;
> undef @header;
>
> while (<TMP>) {
> push @header, $_;
> chomp;
> if (/^From: /) { # what we want
> if (m/From:\s+(?:.*?)<(.*)>(?:.*)$/)
> {
> $who = $1;
> }
>
> else
> { # wasn't angled so hope for the best
> s/^From:\s+(.*?)(?:[()\s]+.*)$/$1/;
> print STDERR "From [$_]\n";
> $who = $_;
> $who =~ tr/\"//d; # remove quotes
> }
> }
>
>
> last if ($_ eq "\n"); # this could burn you if blank line isn'twline
>
> last if ($_ eq "\r\n");
> }
> @body = <TMP>;
> close TMP;
> if ((!defined($who) || ($who eq ""))) {
> print STDERR "Not able to determine who it's from (skipping $file)\n";
> }
> else
> {
> $time = localtime();
> print "From $who $time\n";
> print @header;
> print "\n";
> print @body;
> print "\n";
> }
> }
>
More information about the lugos-list
mailing list