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
...
####
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/
####
$output_str = "@subject[$j];@failed[$j];@monthi[$j]/@dayi[$j]/@yeari[$j];@routerval[$j];" .
"@tag[$j];@montho[$j]/@dayo[$j]/@yearo[$j];@lotCode[$j];@commentso[$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;