my %tr; sub normalise { my $s = shift; my $from = substr $s, 0, 4; my $tr = $tr{$from} ||= eval qq{ sub { tr{$from}{1234} } }; &$tr for $s; $s; }