Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
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 romping around the Monastery: (4)
As of 2021-01-17 12:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?