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";
}
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|