Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
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?
[marto]: good music, is good music, ignore the genre :P
[Corion]: marto: Thank you, reminds me of good times ;))
[Corion]: holli: If you are in Frankfurt, I can recommend the Ubahnkontrollöre - they have two gigs, one on the 28th Dec., the next in May 2018
[Corion]: They don't do new material anymore, but the old stuff is good enough IMO :)

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (7)
As of 2017-11-18 19:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:













    Results (277 votes). Check out past polls.

    Notices?