in reply to Re^2: substituting values in an array
in thread substituting values in an array
In this case, the golf is not just for leisure. You'd have to dig out the XS to write a faster solution. On a large array, it's about twice as fast as using map, and about 50% faster than using (admittedly somewhat more readable) for and if blocks.
Also quite fast (though just a teeny bit slower) would be:
$_ = ($_ > 200) ? 200 : $_ for @array;
... though that might degrade quite badly on a tied array as it performs unnecessary extra FETCH and STORE operations.
|
|---|