UBB.Dev
Posted By: Ian_W Making a script readable! - 03/25/2002 10:10 PM
Hi,

I have just been given a long script that for some reason is all in one line.

It makes reading of it almost impossible.

Is there any way to change this to be over many lines?

I am not that familiar with cgi scripting, but will I break the script if I break the lines in the wrong place.

Regards,

Ian
Posted By: tackaberry Re: Making a script readable! - 03/25/2002 10:19 PM
try word wrap in your text editor laugh
Posted By: Ian_W Re: Making a script readable! - 03/25/2002 10:53 PM
I tried that - and whilst it improves things it is by no means any easier to read frown

Ian
Posted By: Dave_L Re: Making a script readable! - 03/25/2002 11:15 PM
Line breaks in Perl are ignored (unless they're in the middle of a quoted string, identifier, etc.), so you shouldn't have any problems splitting it up onto multiple lines.

A script I downloaded was formatted the same way. I suspect the author did it intentionally to discourage people from making changes to it.

I thought I saw a utility for automatically reformatting a Perl script, but can't remember where.

[edit]
Hmmmm ...
When you say it's one line, are there embedded line feed characters visible? That could happen if you try to view a Unix-formatted text file in Notepad on windows. If that's the case, try using Wordpad or another text editor which handles the different line terminators correctly.
Posted By: Mark Badolato Re: Making a script readable! - 03/26/2002 4:30 AM
You could always try a REALLY hackish thing like loading the script into a variable then have perl parse to add linefeeds after each semicolon
Posted By: Dave_L Re: Making a script readable! - 03/26/2002 4:57 AM
This is probably the utility I was thinking of: PerlTidy .
Posted By: BlackTyranitar Re: Making a script readable! - 03/30/2002 4:38 PM
quote:
Originally posted by Mark Badolato:
You could always try a REALLY hackish thing like loading the script into a variable then have perl parse to add linefeeds after each semicolon

thats not REALLY hackish, more like 3 seconds tipsy
Posted By: Ian_W Re: Making a script readable! - 03/30/2002 5:40 PM
It might be 3 seconds to you wink - but I haven't a clue how to do that - any clues? smile

Ian
Posted By: BlackTyranitar Re: Making a script readable! - 03/30/2002 6:11 PM
[code][/code]man im forgetting perl shocked too much php lately
script.cgi has to be chmodded to 777 or has to be writeable and readable(666) at least
Posted By: Ian_W Re: Making a script readable! - 03/30/2002 7:24 PM
Thanks - I will give it a go....
Posted By: Matt Jacob Re: Making a script readable! - 03/30/2002 8:25 PM
I would do as Dave suggested and use Perltidy -- it'll do what you need.
© UBB.Developers