One quick and dirty solution would be to ensure that higher (and therefore longer) keys are substituted first.
--foreach $key (sort { $b <=> $a } keys %method) { $message_ref->[0] =~ s/$key/$method{$key}/; }
"The first rule of Perl club is you do not talk about
Perl club."
-- Chip Salzenberg
In reply to Re: Matching and replacing
by davorg
in thread Matching and replacing
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |