Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^2: Python dict to perl hash

by frozenwithjoy (Priest)
on Mar 30, 2015 at 15:24 UTC ( [id://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?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (2)
As of 2024-04-26 02:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found