I am seeing an error reading: Use of uninitialized value $email in print at /home/hesco/lib/perl/ETC/parse_email.pl line 13., when I invoke a pipe, like this:

cat /home/hesco/lib/perl/ETC/etc/vote2009.mbox | formail -s | /home/he +sco/lib/perl/ETC/parse_email.pl
That code begins like so:

#!/usr/bin/perl use strict; use warnings; use Data::Dumper; use lib qw( /home/hesco/lib/perl ); use parser; my $email = $ARGV[0]; my($start,$to,$name,$pid,$key); open('EMAIL','>','/tmp/email_throw_away'); print EMAIL $email; # <--- error here ??? close(EMAIL);
and if I pipe that cat output to less instead of through my filter, I get what appears to be an email. How is it that value would be uninitialized?

So next I copied my .mbox file to itself, giving it a new extension of .sample, and edit the .sample so that it contains ONLY a single email, dropped the formail invocation from my pipe and try this:

cat /home/hesco/lib/perl/ETC/etc/vote2009.sample | /home/hesco/lib/per +l/ETC/parse_email.pl
yielding the same result:

Use of uninitialized value $email in print at /home/hesco/lib/perl/ETC +/parse_email.pl line 13.
And now I am really confused.

-- Hugh

UPDATE:

mortiz, zwon: So you are right. This seems to work much better:

cat /home/hesco/lib/perl/ETC/etc/vote2009.mbox | formail -s | /home/he +sco/lib/perl/ETC/parse_email.pl -
Now to figure out why my formail -s is only giving me the first email in the mbox file. Thanks folks!

Never mind on that. formail -s expects the filter as an argument to the -s switch, not to pipe STDOUT to the filter. Issue resolved with:

cat /home/hesco/lib/perl/ETC/etc/vote2009.mbox | formail -s /home/hesc +o/lib/perl/ETC/parse_email.pl -
if( $lal && $lol ) { $life++; }

In reply to filter denies existence of input by hesco

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.