use vars '$msg' instead of stash('msg')

Of course, this is Perl, so TMTOWTDI