Another alternative would be to move the hash definition
into the function definition, since that is the only place
where that is used. This satisfies both the desire to
modularize your code, and the need to the have the hash
defined everwhere that the msg function is called. In this
case the definition for your msg subroutine would be:
sub msg {
my $msgs = { '200' => 'OK',
'400' => 'Bad Request',
'403' => 'Forbidden',
'404' => 'Not Found',
'500' => 'Internal Sever Error',
};
my $msg_num = $_[0];
my $msg_txt = "$msg_num $msgs{$msg_num}";
print "HTTP/1.0 $msg_txt\n";
}