The output record separator may help you do what you want:
$\ = $endofline;
print OUTFILE $processed_string; # Appends the wanted end of line corr
+ectly
This may be a problem if you are not writing to OUTFILE only while $\ is changed. If you can limit the change to a defined scope (ie:
localize) that would probably be better:
{
local $\ = $endofline;
my $old_handle = select OUTFILE;
# Write to OUTFILE only
while (<>)
{
process($_);
print $_; # write to selected handle (OUTFILE) and append $\
}
select $old_handle;
}
# $\ has its old value again