in reply to calling a sub from an if statement

I just wanted to say that
sub msg { $msg_num = @_[0]; # ...
is not necessarily what you want.
@_[0] # An array slice $_[0] # The first element of the array @_ (usually passed to the subro +utine)