Why are you trying to force your data into being a1 command-line parameter? Normally, piped data is accessed by reading it from STDIN:
#!/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);
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.


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

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.