Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
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
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 scrutinizing the Monastery: (9)
As of 2020-10-01 18:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (18 votes). Check out past polls.

    Notices?