1. I don't know if it is possible with dbmopen/dbmclose because I hardly use this
2. Yes, you can:
or in a different way:foreach my $key (keys %hash){ print "$key => $hash{$key}\n"; } # or shorter: foreach (keys %hash){ print "$_ => $hash{$_}\n"; }
while ( my ($key, $value) = each (%hash)){ print "$key => $value\n"; }
shift, unshift, push or pop don't work with hashes; just add a hashelement with a new key, and it is about unshift or push: $hash{newKey} = 'newValue';
3. get all keys with my @keys = keys %hash; and choose which one you want... e.g. with: my $firstKey = ( keys %hash)[0];
Beware that hashes are not sorted, so getting the first key might not be exactly what you want. Or do you work with Tie::Hash?
Best regards,
perl -le "s==*F=e=>y~\*martinF~stronat~=>s~[^\w]~~g=>chop,print"
In reply to Re: Fun with arrays and hashes
by strat
in thread Fun with arrays and hashes
by shaolin_gungfu
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |