Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^3: better way to convert a string into an array and an hash

by Rhose (Priest)
on Oct 05, 2004 at 16:08 UTC ( #396639=note: print w/ replies, xml ) Need Help??


in reply to (Golf!) Re^2: better way to convert a string into an array and an hash
in thread better way to convert a string into an array and an hash

I'm not a golfer, but...

tr/:/,/;%h=eval;@a=keys%h;

Update

y/:/,/;%h=eval;@a=keys%h;

Update 2

If the ordering of @a is important, how about

@a=/(\d+):/g;y/:/,/;%h=eval;


Comment on Re^3: better way to convert a string into an array and an hash
Select or Download Code
Replies are listed 'Best First'.
Re^4: better way to convert a string into an array and an hash
by dragonchild (Archbishop) on Oct 05, 2004 at 17:04 UTC
    This doesn't preserve the order of the keys. That's a problem.

    Being right, does not endow the right to be rude; politeness costs nothing.
    Being unknowing, is not the same as being stupid.
    Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
    Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (9)
As of 2015-07-29 08:21 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 (261 votes), past polls