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

Answer: Removing carriage returns from source code

by tachyon (Chancellor)
on Sep 07, 2001 at 05:14 UTC ( #110810=categorized answer: print w/replies, xml ) Need Help??

Q&A > CGI programming > Removing carriage returns from source code - Answer contributed by tachyon

In case you are unfamiliar with using Perl directly on the command line the -pi.bak part makes a backup file with a .bak extension before the -e (for execute) executes the 's/this/that/g' on every line of For a more permanent solution just write a little script like this:

#!/usr/bin/perl -w -i.bak use strict; while (<>) { s/this/that/g; print; }

If you call this script say you use it like this:

C:\>type #!/usr/bin/perl -w -i.bak use strict; while (<>) { s/this/that/g; print; } C:\>type this.txt this this this this C:\>perl this.txt C:\>type this.txt that that that that C:\>type this.txt.bak this this this this C:\>

Just change this and that to whatever you want. For Mac that will be \r and \n respectively.

Log In?

What's my password?
Create A New User
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2020-09-24 05:42 GMT
Find Nodes?
    Voting Booth?
    If at first I donít succeed, I Ö

    Results (132 votes). Check out past polls.