Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Deconstructing that Perl' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Deconstructing that Perl
Authored by: Gee4orce on Dec 08, '00 10:44:04AM

Thought you might like to know how that Perl works:

perl -pi -e 's/\r/\n/g' <filename>

OK let's break that down:

perl - pretty obvious, runs the Perl interpreter

-p - says to perl, 'for every line in the file, do this...'
-i - says to perl, 'send output back to the same file you read from'

-e - says 'run the next bit as if it's a script'

s/\r/\n/g : This is the bit that does the work

s// - the substitute command, The '/' are just separators
\r - a 'return'
\n - a 'newline
g - means 'global', ie for every ocurrance.

So, put that together, and it means 'substitute every r with n'

(PS - I couldn't get the backslashes to display in this message !)

:)



[ Reply to This | # ]
Backslashes...
Authored by: robg on Dec 08, '00 11:25:07AM

Yea, it's a bit of a problem due to a bug in the way that Geeklog handles them at present.
The only way to make sure they show up (along with frontslashes, brackets, quotes, etc) if
you post in HTML is to encode them:

&#039; = '
&#047; = /
&#060; = <
&#062; = >
&#092; =

I edited your post in the database to insert the characters so it reads correctly. This bug will
hopefully be addressed in the next release...



[ Reply to This | # ]