in reply to Delete keys in hash if they exist in another hash
I may be misunderstanding you, but I think you just want:
delete @hash{keys %end};
Here's a simple program that demonstrates it:
#!/usr/bin/perl use strict; use warnings; my %hash = (one => 1, two => 2, three => 3); my %end = (two => 2); delete @hash{keys %end}; print "$_ => $hash{$_}\n" for keys %hash;
By the way, I've taken my specification from your post where you say "delete the keys in %hash if they exist in %end", rather than your code which seems to do the opposite.
"The first rule of Perl club is you do not talk about
Perl club."
-- Chip Salzenberg
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Delete keys in hash if they exist in another hash
by tgolf4fun (Novice) on Nov 13, 2004 at 00:23 UTC |