Scripting
>>
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; }
Please enable JavaScript to view the
comments powered by Disqus.