On 02/11/2016 19:35, Andy Bach wrote:
On Wed, Nov 2, 2016 at 9:13 AM, Mark Coetser <m...@tux-edo.co.za
<mailto:m...@tux-edo.co.za>> wrote:
$parser->ignore_errors(1);
$parser->output_to_core(1);
my $entity = $parser->parse(\*STDIN);
my $error = ($@ || $parser->last_error);
#get email headers
...
my ($header, $body);
{ local $/ = "";
$header = <STDIN>;
undef $/;
$body = <STDIN>;
}
Seems like you've already consumed STDIN in the parser, so there's
nothing left in your local block to copy. My guess is you want to print
$entity to MAIL. Note, you should always use a conditional on open
stmts, often
open(my $mh, "|$sendmail $vac) or die "can't exec $sendmail: $!";
Using a lexical, instead of a NAME is modern perl, you still do
print $mh "header: ...
maybe (perldoc MIME::Parser):
### Congratulations: you now have a (possibly multipart) MIME
entity!
$entity->dump_skeleton; # for debugging
Again thanks for the help, to simply things how can I read stdin into a
variable that I could parse twice. I tried to simplfy things as follows
but get the same result..
#!/usr/bin/perl
my $vacation_forward = "vacation\@domain.com";
open(OUT, "|/usr/sbin/sendmail $vacation_forward") or die ("Can't
sendmail - $!");
while (my $line = <STDIN>) {
$email_addr_to = $1 if $line =~ /^To: (.*)$/;
print OUT;
}
close (OUT);
if ($email_addr_to) {
print "$email_addr_to\n";
}
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/