Well, more perlish way to do some of this:
if ( /^Subject:\D+(\d+)/ ){ # if you can be sure of the '#' before the digits, use this # if ( /^Subject:.*#(\d+)/ ) not that it buys you much push @subject, $1; next; } # if /subject ...
push is much better than your $i++ which may be getting messed up, the way your snippet looks. I'm guessing your open(OUTPUT ... is supposed to be outside the while {...}.

Not as snazzy as the ever terse, er, tidy io's suggestion, but:

if ( /\s*Out Comments\s*(.*)$/ ) { push @out_comments, $1; while (<>) { # quit on a blank line or ------- last if /^\s*$/ or /^\s*[-]+\s*$/; s/^\s*//; # get rid of spaces at the beginning push @out_comments, $_; } next; } # if /Out Comments/
not the 'strictest' of methods (re-while-ing the <> is frowned on by pendants) but if you're confident of your data format, it works. I get the impression you expect only one msg per email, so your arrays aren't needed, so scalars might be better (that is, $i is usually ends up '1'). Just do "$subject = $1;" and "$out_comment .= $_;" for the inner while loop. You'll avoid typos by:
$output_str = "@subject[$j];@failed[$j];@monthi[$j]/@dayi[$j]/@yeari[$ +j];@routerval[$j];" . "@tag[$j];@montho[$j]/@dayo[$j]/@yearo[$j];@lotCode[$j];@com +mentso[$j]\n"; # or, if you've gone to scalars $output_str = "$subject;$failed;$monthi/$dayi/$yeari;$routerval;" . "$tag;$montho/$dayo$/$yearo;$lotCode;$commentso\n"; print OUTPUT $output_str; print $output_str;
And, last but definitely not least; perl -w/use strict, if you're gonna use the tools, use them *safely*. You'll be glad you did later on.

a


In reply to Re: Better description of my concatenating problem by a
in thread Better description of my concatenating problem by ploaiza

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.