in reply to Re: Sorting - lower to upper
in thread Sorting - lower to upper
I'm always a bit wary of code that looks like that, especially when it doesn't have the big warning sign to the right that says:... map { tr/a-zA-Z/A-Za-z/; $_ } ...
Warning This map alters its incoming arguments as well as generating the desired list. While it is safe in this particular usage, use caution when copying this to another segment of code.
In other words, I'd have written that as:
which ensures that I get the desired output value without seriously mangling my input value as a side-effect.... map { (my $x = $_) =~ tr/a-zA-Z/A-Za-z/; $x } ...
-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.
|
|---|