No such thing as a small change | |
PerlMonks |
Regular Expression Tweakingby dooberwah (Pilgrim) |
on Feb 20, 2002 at 23:25 UTC ( [id://146659]=perlquestion: print w/replies, xml ) | Need Help?? |
dooberwah has asked for the wisdom of the Perl Monks concerning the following question:
I am writing a small script to format a text file. My text file isn't just a normal document, it's a poem. I'm dumping the end result into an HTML table to make it look pretty.
That part isn't actually very interesting, because it's so simple. The more interesting (?) tidbit is this: $line =~ /^$/ or chomp ( $line ); What is it? Well, what it does is removes the newline from the end of the line, unless the only thing on the line is a newline character. This is so normal lines are chomped, and lines that separate the stanzas aren't. Is this the best way to do it? It runs fine ... and hey, TMTOWTDI, but is it the best (fastest, cleanest, prettiest, safest)? Comments from those wiser than I would be greatly appreciated.
-Ben Jacobs (dooberwah)
Back to
Seekers of Perl Wisdom
|
|