Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^2: Python dict to perl hash

by frozenwithjoy (Priest)
on Mar 30, 2015 at 15:24 UTC ( #1121851=note: print w/replies, xml ) Need Help??


in reply to Re: Python dict to perl hash
in thread Python dict to perl hash

I think replacing this:

$x =~ s/['\s+]//g; my %hash = split /[:,]/, $x;

with this:

$x =~ s/'\s*:\s*'/' => '/g; my %hash = %{ eval "{$x}" };

would make it less breakable (but still breakable if and keys or values contained something like "' : '").

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2023-03-26 21:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which type of climate do you prefer to live in?






    Results (63 votes). Check out past polls.

    Notices?