Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Perl Files Corrumpted

by ikegami (Patriarch)
on Jan 26, 2010 at 18:31 UTC ( #819734=note: print w/replies, xml ) Need Help??


in reply to Perl Files Corrumpted

When opening those perl files with a code editor now I dont see my code but the mess you normally see when you accidently transferred a perl file in binary mode

What does that mean? Using FTP's binary mode (between non-EBCDIC systems), the worse that will happen is the line endings getting messed up. Is that what you mean?

Care to give a dump of a portion of the file? Maybe something like

od -c file | head -30

Replies are listed 'Best First'.
Re^2: Perl Files Corrumpted (\r)
by tye (Sage) on Jan 27, 2010 at 06:44 UTC

    Indeed, dropping the "\r" from the traditional Win32 line ending of "\r\n" means that Notepad.exe (and others of the more stupid Win32 programs) don't recognize the bare "\n" as a real line ending. So you get all of the code run together in one big line that looks quite like an unintelligible mess.

    My first suggestion would be to get a better editor. But restoring the line endings to "\r\n" is pretty easy. If you have (a native) Perl on Win32, then you can do that as simply as:

    perl -pi-i -e "BEGIN{@ARGV=map{glob}@ARGV}" *.pl REM check the new *.pl file contents REM if everything looks good, then: del *.pl-i

    Guru meditation

    - tye        

      You can also do that with nothing more than Wordpad from Windows Progams->Accessories. It will display the file properly. If you hit the save button, it will save the file with the correct \r\n line endings.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2022-08-19 14:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?