Software >> Development >> Languages >> Perl >>  How to return a hash from a subroutine

Example : %mthnames = monthnames(); foreach $m (keys %mthnames) { printf "%s = %s\n",$m,$mthnames{$m}; } sub monthnames() { my %hash; $hash{"01"} = "Jan"; $hash{"02"} = "Feb"; $hash{"03"} = "Mar"; return %hash; }