Forum Moderators: open

Message Too Old, No Replies

perl, line breaks and Notepad

I can't read the darn thing

         

driven_snow

12:58 pm on Sep 25, 2003 (gmt 0)

10+ Year Member



I am trying to edit a perlscript . . and of course I'm using Notepad as anything else I know of will cause the script not to work.

But all the line breaks are squares .. and I can't find anything. It's a mess.

If I copy / paste into word pad, it's all organised neatly and easy to read, but if Wordpad touches the thing ( and that includes editing in wordpad then pasting into notepad ) then it stops working.

The author obviously could use line breaks, because when viewed in wordpad everything is neatly organised.

I don't understand.

marcs

1:18 pm on Sep 25, 2003 (gmt 0)

10+ Year Member



I'm going to guess you grabbed this script from the server and it is a Unix server. Linebreaks are there, they're simply not the same as on MS based systems.

FTP the file in ASCII mode from the server to your PC (same for the other way around) and you should have no trouble with linebreaks.

Slade

1:24 pm on Sep 25, 2003 (gmt 0)

10+ Year Member



I use vim for most of my text editing. It can deal with those types of files without any fuss. Downside is you do have to learn to use it...

[vim.org...]

coopster

1:37 pm on Sep 25, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Why is the HTML/Perl/PHP code I copied to my editor in a mess?

The code that appears garbled with rectangular boxes has each line terminated by carriage returns (CR) instead of carriage return and line feed pairs (CRLF) or just line feeds (LF). If you use an editor like Notepad that does not recognize carriage returns as line terminators, all your lines will run into each other.

A Note on Windows Notepad: If you are writing your scripts using Windows Notepad, you will need to ensure that your files are saved with the extension you desire. (Notepad adds a .txt extension to files automatically unless you take one of the following steps to prevent it.) When you save the file and are prompted to provide a name for the file, place the filename in quotes (i.e. "hello.cgi"). Alternately, you can click on the 'Text Documents' drop-down menu in the save dialog box and change the setting to "All Files". You can then enter your filename without quotes.

I also find that if I transfer files from the server to my desktop using binary mode rather than ASCII, I can open, edit, save and transfer the file using Wordpad successfully. Binary mode preserves the CR/LF correctly.

driven_snow

1:55 pm on Sep 25, 2003 (gmt 0)

10+ Year Member



Thank you so much Coopster .. I downloaded with binary mode and now it's all nice an neat and organised . .

You're awesome.