Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^3: Newbie: uses/limits of perl in editing files

by Sixtease (Friar)
on Nov 23, 2007 at 14:32 UTC ( [id://652573]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Newbie: uses/limits of perl in editing files
in thread Newbie: uses/limits of perl in editing files

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"; }

Replies are listed 'Best First'.
Re^4: Newbie: uses/limits of perl in editing files
by wherethewild (Novice) on Nov 23, 2007 at 14:48 UTC
    unfortunately, still a problem. Thanks for all the help so far though, it's certainly moving me forward much faster than if I was left to beat my head against the screen alone!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://652573]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (2)
As of 2024-04-19 18:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found