commit bbdbef1aa611793df3db28ba27fa2ef8bb34cfad from: Omar Polo date: Sat Apr 01 16:03:52 2023 UTC make GotMArc::parse return an hash reference instead of a list of strings commit - 53bed50154a249d1263a3066d28500b3541539d5 commit + bbdbef1aa611793df3db28ba27fa2ef8bb34cfad blob - a1c53732ad9b93159612c229b7eda9d445762de2 blob + c57cf11f9f81d7c1e856642def029495e5b397c6 --- GotMArc.pm +++ GotMArc.pm @@ -55,7 +55,8 @@ sub parse { my ($time, $id) = split /\./, basename($fname); my $mid = "$time.$id"; - return ($level, $fname, $mid, $date, $from, $subj); + return {level => $level, fname => $fname, + mid => $mid, date => $date, from => $from, subj => $subj}; } sub readall { blob - 8f291686b1442a49b81b17cfe468f87b9a6d5084 blob + 44cac2bf265eeab9be0d4e2fd15357ec586d578c --- mexp +++ mexp @@ -58,22 +58,22 @@ sub humanize { my $tid; while (<>) { - my ($level, $fname, $mid, $date, $from, $subj) = parse; + my $mail = parse; - $tid = $mid if $level == 0; + $tid = $mail->{mid} if $mail->{level} == 0; die "unknown tid" unless defined $tid; - my $dest = "$outdir/mail/$mid.html"; + my $dest = "$outdir/mail/$mail->{mid}.html"; open(my $fh, '>', "$dest") or die "can't open $dest: $!"; - initpage $fh, $subj; + initpage $fh, $mail->{subj}; - open(my $mshow, "-|", "mshow", "-nNA", "text/plain", $fname) + open(my $mshow, "-|", "mshow", "-nNA", "text/plain", $mail->{fname}) or die "can't exec mshow: $!"; - open(my $text, '>', "$outdir/text/$mid.txt") - or die "can't open $outdir/text/$mid.txt: $!"; + open(my $text, '>', "$outdir/text/$mail->{mid}.txt") + or die "can't open $outdir/text/$mail->{mid}.txt: $!"; my @hdrs; while (<$mshow>) { @@ -86,7 +86,7 @@ while (<>) { } say $text ""; - thread_header $fh, $tid, $mid, \@hdrs; + thread_header $fh, $tid, $mail->{mid}, \@hdrs; print $fh "
";
 	while (<$mshow>) {
@@ -96,7 +96,7 @@ while (<>) {
 	print $fh "
"; # generate the listing for the exported parts - open(my $parts, '-|', 'mshow', '-t', $fname) + open(my $parts, '-|', 'mshow', '-t', $mail->{fname}) or die "can't exec mshow: $!"; my $partno = 0; @@ -127,10 +127,10 @@ while (<>) { say $fh "" if $partno > 0; - my $encmid = urlencode $mid; + my $encmid = urlencode $mail->{mid}; my $enctid = urlencode $tid; print $fh "