Had a reeeeeaaaaly vague recollection and the Perl Cookbook (Ch 1 section 19) does actually offer $_ = join(' ', split(' ')); as an alternative to these three substitutions:
s/^\s+//; s/\s+$//; s/\s+/ /g;
to strip and canonicalize to single spaces; and does offer this trim sub:
sub trim { my @out = @_ ? @_ : $_; $_ = join(' ', split(' ')) for @out; return wantarray ? @out : "@out"; }
Edit: That being said, I don't recall having seen this construct in the wild otherwise and had the vaguest of hunches that PC mentioned anything like this so I'd hardly call it a "common idiom" either.
The cake is a lie.
The cake is a lie.
The cake is a lie.
In reply to Re^8: What esteemed monks think about changes necessary/desirable in Perl 7 outside of OO staff
by Fletch
in thread What esteemed monks think about changes necessary/desirable in Perl 7 outside of OO staff
by likbez
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |