Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Deleting hash entry

by broquaint (Abbot)
on Dec 16, 2003 at 15:05 UTC ( [id://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

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (None)
    As of 2024-04-25 01:31 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found