#!/usr/bin/perl use warnings; use strict; our @to; our @cc; our @id; our $emptyline=0; if (defined $ARGV[0] and -f $ARGV[0]) { open (MAIL, "<$ARGV[0]") or die "cannot open $ARGV[0]\n"; #while (my $line= && ($emptyline == 0) ) { while (my $line= ) { chomp $line; my $header=""; my $content=""; if ($line =~ /^(.*?):.*[ ,<](.*?@.*?)[>, ]/ || $line =~ /^(.*ID?):.*[ ,<](.*?)[>, ]/) { $header=$1; $content=$2; if ($header eq "From") { push(@to, $content); } if ($header eq "To") { push(@cc, $content); } elsif ($header eq "Cc") { $line =~ /:(.*)$/; my @ccs=split(/,/, $1); foreach my $addr (@ccs) { if ($addr =~ /<(.*)>/) { push(@cc, $1); } else { push(@cc, $addr); } } } elsif ($header eq "Message-ID") { push(@id, $content); } } $emptyline++ if (length($line) == 0); } close (MAIL); } foreach my $item (@to) { print " --to \"$item\""; } foreach my $item (@cc) { print " --cc \"$item\""; } foreach my $item (@id) { print " --in-reply-to \"$item\""; }