in reply to Using eval, but always undef?

in perl it's ¹ => not : separating keys and values.

maybe you wanna use a JSON module for conversion?

Cheers Rolf

¹) normally, commas are allowed if you quote the key

Replies are listed 'Best First'.
Re^2: Using eval, but always undef?
by ultranerds (Hermit) on Mar 01, 2012 at 17:53 UTC
    Mmm ok, I was hoping it was simpler than that. Maybe I'll just do:

    $test =~ /\Q"type":"ServiceException",/

    ...on the XML string, so I can see if it is as "bad" file :)

    Thanks for the replies though.

    Cheers

    Andy

      It is simple (JSON).

      use JSON; my $json_string = q|{ "error":{ "type":"ServiceException", "code":108, "message":"(#108) No results founds" } }|; my $perl_ref = decode_json($json_string); print $perl_ref->{error}{type}, $/; __END__ ServiceException

      Don't fudge it. Use the right tools. Everything else is false economy.