how to print the contents of perl hash?
Method1:
print "$_ $h{$_}\n" for (keys %h);
Method2:
while (my ($k,$v)=each %h){print "$k $v\n"}
Method3:
print "@{[%hash]}";
Method4:
print map { "$_ $h{$_}\n" } keys %h;
Method5:
print "$_ $h{$_}\n" for keys %h
Method6:
foreach(keys %my_hash) { print "$_ / $my_hash{$_}\n"; }
Method7:
map {print "$_ / $my_hash{$_}\n"; } keys %my_hash;
Method8:
print map {$_ . " "} %h, "\n";
Labels: create a perl hash, initialize a perl hash, print a perl hash
0 Comments:
Post a Comment
Note: only a member of this blog may post a comment.
<< Home