in reply to doing tr/// on-the-fly?

If you need to use a runtime-defined tr/// on more than one line, re-evaling it for each line gets very expensive. It's better to eval a subroutine into existance and use that:

#! perl -slw use strict; sub makeTR{ return eval "sub{ \$_[ 0 ] =~ tr[$_[0]][$_[1]] }"; } my $myTR = makeTR( 'abcd', '1234' ); for my $str ( qw[ abcd aabbccdd xx axbxcxdx ] ) { my $copy = $str; my $count = $myTR->( $copy ); print "Before: $str After: $copy count: $count"; } __END__ c:\test>junk62 Before: abcd After: 1234 count: 4 Before: aabbccdd After: 11223344 count: 8 Before: xx After: xx count: 0 Before: axbxcxdx After: 1x2x3x4x count: 4

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"I'd rather go naked than blow up my ass"