Here's my guess:
Your file has Windows newlines (cr/lf), which your editor/viewer can deal with and shows it correctly. Then you add unix newlines (lf) on the lines you edit. Now there are mixed cr/lf and lf newlines, which confuses the editor and it shows the cr characters.
If I'm correct, then I recommend either preprocess the file with the dos2unix tool or address this in the perl script itself
update: The modified while loop could look like this:
while (my $line = <$rfh>) { chomp $line; if ($line =~ m/^HEADER/) { my $number = 42; # change to whatever number you want to use $line .= $number; } if ($line =~ m/^REMARK/) { print {$wfh} "Extra line\n" # Change to whatever extra line yo +u want } print {$wfh} $line, "\n"; }
In reply to Re^3: Newbie: uses/limits of perl in editing files
by Sixtease
in thread Newbie: uses/limits of perl in editing files
by wherethewild
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |