for (@{$msg->body}){ s/\bblah\b/something/g; print; }
It does nearly the same thing as your original loop, but it has a slightly different notion of where a word ends.
If you really want whitespace delimited words you can change the regular expression to read
s/(?<=^| )blah(?= |$)/something/g;
In reply to Re: A regex question
by moritz
in thread A regex question
by vxp
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |