Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
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 taking refuge in the Monastery: (7)
As of 2014-12-21 14:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (106 votes), past polls