[Wellington-pm] I must be stupid...
Andrew McMillan
andrew at morphoss.com
Tue May 5 03:48:42 PDT 2009
... but you probably already knew that :-)
Can someone please explain to me why I get a difference between these:
$text =~ s/\s+/ /s;
vs.
$text = join( ' ', split( /\s+/s, $text) );
Assuming that $text is a multi-line string beforehand, and I want it to
be a single-line string afterwards.
The first one doesn't do what I want - to replace sequences of
whitespace (including newlines) with a single space. The second seems
remarkably long-winded to achieve what I want, and quite probably less
efficient than one might hope, as well.
I expect that I am missing something blindingly obvious, and an
explanation will no doubt assist my progress along the path to perl
enlightenment.
Yours,
Confused.
------------------------------------------------------------------------
andrew (AT) morphoss (DOT) com +64(272)DEBIAN
I have not seen high-discipline processes succeed in commercial
settings. - Alistair Cockburn
------------------------------------------------------------------------
More information about the Wellington-pm
mailing list