Beefy Boxes and Bandwidth Generously Provided by pair Networks Joe
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

(tye)Re: newlines for windows from unix

by tye (Sage)
on Jun 07, 2001 at 15:38 UTC ( [id://86600]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to newlines for windows from unix

perl -i.can -please file is a general-purpose newline fixer. When you run it on Windows, it will turn Unix-style newlines into Windows-style newlines (and will leave Windows-style newlines alone). When you run it on Unix, it will turn Windows-style newlines into Unix-style newlines (and will leave Unix-style newlines alone).

Unfortunately, converting to and from Mac-style newlines isn't covered by this.

Don't forget to eventually throw the backups into the trash can:

rm *.can del *.can

If you want to use wildcards with this command unders Windows, then put the following into a file called "atch.pm" under perl/site/lib: @ARGV= map { glob } @ARGV; then use a command like this: perl -Match -i.can -please *.ext

This message was sponsored by The World League For Cute But Useful Idioms.

Update: {grumble} ChemBoy just made me realize that this only works when run under Win32. Oh well, perl -i.can -pley/\\r//d should work even for Win32 files on a Mac and on Mac files under Unix and Win32, except that you should not double the \ under Win32 and I don't know whether you should on a Mac. Note that this solution also removes "\r"s from the middle of lines. We need to remove them from front of lines for converting between Win32 and Mac formats and from the ends of lines for Win32-to-Unix conversion.

        - tye (but my friends call me "Tye")

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://86600]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.