Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Deleting undef values from a hash

by davido (Archbishop)
on Dec 14, 2003 at 07:47 UTC ( #314619=note: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    my %hash = ('First' => 1, 'Second' => undef );
    print "First\n" if exists $hash{'First'};
    ...
    __OUTPUT__
    First
    Second
    
  2. or download this
    while ( my ( $key, $val ) = each %hash ) {
        delete $hash{$key} if not defined $val;
    }
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (13)
As of 2015-05-04 17:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    In my home, the TV remote control is ...









    Results (94 votes), past polls