in reply to Re^7: What esteemed monks think about changes necessary/desirable in Perl 7 outside of OO staff
in thread What esteemed monks think about changes necessary/desirable in Perl 7 outside of OO staff
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.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^9: What esteemed monks think about changes necessary/desirable in Perl 7 outside of OO staff
by Tux (Canon) on Sep 15, 2020 at 16:39 UTC | |
by Your Mother (Archbishop) on Sep 16, 2020 at 07:14 UTC | |
by LanX (Sage) on Oct 02, 2020 at 12:09 UTC | |
by LanX (Sage) on Oct 02, 2020 at 12:49 UTC |
In Section
Meditations