use strict;
use warnings;
use Data::Dumper;
my $msg = 'a';
my $mhash;
$$mhash{entries}{$msg}{text} = "This is a http://foo/bar.html test.";
$$mhash{entries}{$msg}{text} =~ s!http://(\S+)![foo]!g;
print Dumper $mhash;
__OUTPUT__
$VAR1 = {
'entries' => {
'a' => {
'text' => 'This is a [foo] test.'
}
}
};