I'm working on some code which is piped some input, calls another program to analyze it, and emails the results back to the user. The core of it is:
my ($analyze_in, $analyze_out); my $kid_pid = open2($analyze_out, $analyze_in, $ANALYZE_PATH); exit 0 unless $kid_pid; while (my $line = <>) { print $analyze_in $line; } close $analyze_in; my @result = <$analyze_out>; die unless open my $sendmail_fh, '|' . $SENDMAIL_CMD; print $sendmail_fh <<EOM; From: $from_addr To: $from_addr Subject: Re: $subject @result EOM close $sendmail_fh;
Functionally, it works just fine. However, in the email I receive, the second and all following lines of the analyzer output are indented one space. This indentation does not occur when running the analyzer directly from a shell prompt. There's also a Python version of the wrapper (the code above is actually from a Perl port of the Python code) and the Python version does not produce this indentation either - comparing the mail received from the Python and Perl versions is how I noticed it in the first place.

Any thoughts on what might be causing this or how to prevent it? (Note that s/^ // is not prevention...)


In reply to Minor formatting oddity with pipes by dsheroh

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.