Stapman
asked on
shift for a hash?
I want to go through my hash
value for value but with foreach (%hash) $_ becomes a value then a key string then a value etc..
Is there a function for a hash which does the same as shift for an array?
Thanks
value for value but with foreach (%hash) $_ becomes a value then a key string then a value etc..
Is there a function for a hash which does the same as shift for an array?
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
#or
while( ($key,$value) = each %hash ){
print "hash{$key} = $value\n";
}
#also, values %hash returns an array containing only the value of each hash entry
#(the same as @hash{keys %hash})
while( ($key,$value) = each %hash ){
print "hash{$key} = $value\n";
}
#also, values %hash returns an array containing only the value of each hash entry
#(the same as @hash{keys %hash})
foreach (keys %hash)
then
$_ is the key to the hash, and, of course, $hash{$_} is the value.