in reply to Re: Remove key/value pairs from a hash
in thread Remove key/value pairs from a hash

It still works... $before is 5, $after is 3

%hash1 = ( key1 => "value1", key2 => "value2", key3 => "value3", key4 => "value4", key5 => "value5", ); @array = qw( key3 key4 ); $before = keys %hash1; foreach (@array){ delete($hash1{$_}); } $after = keys %hash1; print("$before\n"); # 5 print("$after\n"); # 3

The problem is obviously not with delete, but with your data. Why don't you dump the array, the before-hash and the after-hash using Data::Dumper as shown in my first post. That will show the problem with your real data.