in reply to Combining hashes
As for merging, I believe the answer to be no. A hash can not have two keys of the exact same value. You can create a union of them easily enough by usingmy $total = scalar(keys %class1) + scalar(keys %class2) + scalar(keys +%class3); #or my $totb = 0; $totb += $_ for map { scalar keys %$_; } (\%class1, \%class2, \%class3 +);
You will however lose any duplicates.my %new = (%class1, %class2, %class3);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Combining hashes
by MeowChow (Vicar) on May 11, 2001 at 22:08 UTC | |
by Sifmole (Chaplain) on May 14, 2001 at 04:05 UTC |