Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^3: map a hash with a default value or exclude

by PrakashK (Pilgrim)
on Sep 13, 2011 at 19:09 UTC ( #925757=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    %{$self->{info}} = map {@$_} grep {$_->[1]} map {chomp; [split '=', $_
    +, 2];} <$fh>;
    
  2. or download this
    %{$self->{info}} = map {chomp; my ($k, $v) = split '=', $_, 2; $v ? ($
    +k => $v) : (); } <$fh>;
    
  3. or download this
    # assuming default values are in %defaults
    %{$self->{info}} = map {chomp; my ($k, $v) = split '=', $_, 2; $k => $
    +v || $defaults{$k}; } <$fh>;
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (8)
As of 2016-09-26 19:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Extraterrestrials haven't visited the Earth yet because:







    Results (489 votes). Check out past polls.