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!