The results of this formulation are:
Rate substr_lval subst reverse substr_mod s
+ubstr_copy
substr_lval 489949/s -- -9% -37% -67%
+ -69%
subst 539218/s 10% -- -31% -63%
+ -66%
reverse 776376/s 58% 44% -- -47%
+ -52%
substr_mod 1473954/s 201% 173% 90% --
+ -8%
substr_copy 1606272/s 228% 198% 107% 9%
+ --
Not hard to see the problem with $_. That said I'm not sure that what you say about how things shouldn't be in a sub is correct. Shouldn't it factor out since it would be true for all cases?
--hsm
"Never try to teach a pig to sing...it wastes your time and it annoys the pig."