Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Deleting hash entry

by broquaint (Abbot)
on Dec 16, 2003 at 15:05 UTC ( #315066=note: print w/ replies, xml ) Need Help??


in reply to Deleting hash entry

Firstly, the first level of that hash assignment should be using parens and not curly braces. Now in answer to your first question, you will delete the def key in the hash pointed to by $hash{abc}. As for the second question, just test that the hash is empty with the use of keys in a scalar context e.g

use Data::Dumper; my %hash = ( abc => {}, ghi =>{ qw/ two key value pairs / } ); print "before: ", Dumper \%hash; delete $hash{abc} unless keys %{ $hash{abc} }; print "after: ", Dumper \%hash; __output__ before: $VAR1 = { 'abc' => {}, 'ghi' => { 'two' => 'key', 'value' => 'pairs' } }; after: $VAR1 = { 'ghi' => { 'two' => 'key', 'value' => 'pairs' } };
HTH

_________
broquaint


Comment on Re: Deleting hash entry
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (9)
As of 2014-08-23 19:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (178 votes), past polls