in reply to Re: Trimming whitespaces methods
in thread Trimming whitespaces methods
In order for the code to be truly equivalent the s modifier should be used on the substitution or a newline may break it.
I assume you added the \S in the pattern as an improvement, but it should perhaps be noted that it has the effect of leaving a line of only whitespaces untouched, whereas the other ways don't.$_ = " foo\nbar "; s{ ^\s* (\S.*?) \s*$ }{$1}x; print "<$_>"; __END__ < foo bar >
lodin
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Trimming whitespaces methods
by johngg (Canon) on Jun 30, 2008 at 22:33 UTC |