Strictly following the structure of your original code, the open/close probably should have been inside the loop, but that would have resulted in the same file being overwritten on every pass, so I moved them outside, since dumping everything into the same file is more likely to be useful.#!/usr/bin/perl use strict; use warnings; use Data::Dumper; use lib qw( /home/hesco/lib/perl ); use parser; open('EMAIL','>','/tmp/email_throw_away'); while (my $email = <STDIN>) { # Or "my $email = <>"[2] my($start,$to,$name,$pid,$key); print EMAIL $email; } close(EMAIL);
1 Note "a" - singular. You're probably getting multiple messages from formail, but the code you posted only looks at $ARGV[0], which is the first command-line argument, not all arguments. I'm actually mildly surprised that you're even getting the complete first message that way rather than only the first word or first line of the first message.
2 <STDIN> will, unsurprisingly, read only from STDIN. <> will read the contents of any files specified on the command line, or STDIN if no files are given.
In reply to Re: filter denies existence of input
by dsheroh
in thread filter denies existence of input
by hesco
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |