Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

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

by wherethewild (Novice)
on Nov 23, 2007 at 14:24 UTC ( [id://652571]=note: print w/replies, xml ) Need Help??


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

That's it! Wow, let's see how I go at adjusting it all for everything else I have to do to it. The weekend shall be fun.

One problem though, and I guess it has something to do with the \n point you made at the end. Now I have <cr> appearing at the end of every line. I'm sitting on a Linux workstation running RedHat if that is at all helpful (I DID say I know nothing about this!)

cheers
wherethewild

Replies are listed 'Best First'.
Re^3: Newbie: uses/limits of perl in editing files
by Sixtease (Friar) on Nov 23, 2007 at 14:32 UTC

    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"; }
      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://652571]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2024-03-29 11:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found