>Can be rewritten as the shorter and more readable:
> ($name) =~ split /\s+/;
> $string =~ quotemeta;
> @array =~ reverse;
> @vals =~ sort { $a <=> $b };
> $string =~ s/\s+/SPACE/; # looks familiar
> $string =~ m/\w+/; # this too
> @strs =~ m/\w+/; # cool extension
> @strs =~ s/foo/bar/gi; # ditto
Which can of course be written in an immeasuably more legible fashion
using current Perl, a little-known language:
($name) = split /\s+/, $name;
$string = quotemeta($string);
@array = reverse @array;
@vals = sort { $a <=> $b } @vals;
$string =~ s/\s+/SPACE/;
$string =~ /\w+/;
map { m/\w+/ } @strs;
s/foo/bar/gi for @strs;
Although the invention of redundant and obfuscated syntactic
alternatives for operations which are not only perfectly feasible
already but also more readable in their current incarnations seems
to be a not infrequent theme in these documents, one must always
carefully consider whether any scant benefit these cutesinesses
might provide can be truly worth further exacerbating the rampant
inscrutability problems (stemming mainly from punctuation in lieu
of alphabetics and from magically implicit targets, arguments, and
side-effects) for which Perl is already soundly--and not always
undeservedly--derided.
Explicitly saying precisely what you mean is perfectly acceptable--and
usually desirable. Inventing subtleties merely to avoid typing, however,
may not be.
--tom