Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: map a list

by davidrw (Prior)
on Mar 12, 2007 at 20:09 UTC ( #604424=note: print w/replies, xml ) Need Help??


in reply to map a list

I'm a fan of the ternary operator, but i think an approach like this would be clearer:
# LHS = Left-hand side # RHS = Right-hand side my $s = 'a,b=c,e=#f'; my %h = map { $_ .= "=fn($_)" unless /=/; # add a RHS s/#(\w+)/fn($1)/; # change the RHS '#' notation to the ' +fn' notation split( /=/, $_, 2 ); # return the LHS=>RHS mapping (delim'd + by a '=') } split /,/, $s; # split on commas to get the strings for the pai +rs

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://604424]
help
Chatterbox?
[rajesh_perl]: Hi
[rajesh_perl]: thanks for editing it
beech testing firefox 52.0.1
beech me me me me
beech mi
beech eieie
beech .oO( *you* don't exist, I'm only messaging to *me* self),
[beech]: *me

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (6)
As of 2017-03-28 07:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (327 votes). Check out past polls.