Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
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 rifling through the Monastery: (18)
As of 2015-07-28 17:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (258 votes), past polls