in reply to Matching and replacing

Not directly related to your immediate question (which has already been answered adequately by other monks), but if your $key is always numerical, you might gain some speed by using an array instead of a hash. It's up to you to decide whether it is worth refactoring your code :)
$message_ref->[0]=~s/\b$_\b/$method[$_]/ for @method;
Note that:

Update: removed 'e' modifier from regexp - not needed.

CU
Robartes-