Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^3: how to use "delete" with a hash of hash

by muba (Priest)
on Jan 29, 2013 at 05:44 UTC ( #1015805=note: print w/ replies, xml ) Need Help??


in reply to Re^2: how to use "delete" with a hash of hash
in thread how to use "delete" with a hash of hash

Please post a piece of code that demonstrates the problem, including expected result and actual result. I could not reproduce the issue from your problem description.

use Data::Dumper; %hoh = ( 'item1' => { 'key1' => '1', 'key2' => '1', 'key3' => '0' }, 'item2' => { 'key1' => '0', 'key2' => '1' } ); print "Before delete:\n"; print Dumper \%hoh; my $a = "item2"; delete $hoh{$a}; print "\n\nAfter delete:\n"; print Dumper \%hoh; print "$a deleted!" if not exists $hoh{$a};
Before delete: $VAR1 = { 'item1' => { 'key2' => '1', 'key1' => '1', 'key3' => '0' }, 'item2' => { 'key2' => '1', 'key1' => '0' } }; After delete: $VAR1 = { 'item1' => { 'key2' => '1', 'key1' => '1', 'key3' => '0' } }; item2 deleted!

That being said, you should abstain from using $a and $b as variables, as they have special meaning to the sort function.


Comment on Re^3: how to use "delete" with a hash of hash
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1015805]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2014-10-23 10:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (125 votes), past polls