Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Python dict to perl hash

by einhverfr (Friar)
on Mar 30, 2015 at 14:12 UTC ( [id://1121839]=note: print w/replies, xml ) Need Help??


in reply to Python dict to perl hash

Not sure if this is helpful or not but for rot13, there is Crypt::Rot13 on CPAN. Just a reminder to check CPAN for everything first....

Now my code would be simpler:

my $x = ... my %hash = map { s/(^'|'$)// } split /(:|, )/ $x;

That assumes you want something like

%x = ( a => 'n', b => 'o', ...);

But it also looks trivial to convert this to valid json and use that module

Update: On second thought that above approach won't work. I think you will need to do something like:

my $x = ... my %hash = map { my $v = $_; $v =~ s/(^'|'$)//; $v} split /(:|, )/ + $x;

Replies are listed 'Best First'.
Re^2: Python dict to perl hash
by jeffa (Bishop) on Mar 30, 2015 at 16:16 UTC

    This is not on the CPAN: Crypt::Rot26 but it provides twice the security that Rot13 offers.

    jeffa

    L-LL-L--L-LL-L--L-LL-L--
    -R--R-RR-R--R-RR-R--R-RR
    B--B--B--B--B--B--B--B--
    H---H---H---H---H---H---
    (the triplet paradiddle with high-hat)
    
      I am afraid it is on CPAN. If you use the module 'M' from CPAN, your assignment operator will automatically be upgraded with ROT26 support!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (3)
As of 2024-04-25 12:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found