in reply to using Text::Balanced
How do I do that?
Recognize that what you have is JSON and use a JSON module :)
#!/usr/bin/perl -- use strict; use warnings; use Data::Dump qw/ dd pp /; use JSON qw/ to_json from_json /; my $str = q{["listliteral",["ListLiteral",["../classSPL_1_1Operator_1_ +1Instance_1_1ExpressionTree_1_1ListLiteral.html",1,"SPL::Operator::In +stance::ExpressionTree"]]]}; dd( from_json( $str ) ); __END__ [ "listliteral", [ "ListLiteral", [ "../classSPL_1_1Operator_1_1Instance_1_1ExpressionTree_1_1ListLi +teral.html", 1, "SPL::Operator::Instance::ExpressionTree", ], ], ]
Oh, but you say I switched the single quotes for the double quotes ... :P
Well, what you do have is also perl, so use Safe
#!/usr/bin/perl -- use strict; use warnings; use Data::Dump qw/ dd pp /; use Safe; my $str = q{["listliteral",["ListLiteral",["../classSPL_1_1Operator_1_ +1Instance_1_1ExpressionTree_1_1ListLiteral.html",1,"SPL::Operator::In +stance::ExpressionTree"]]]}; dd( Safe->new->reval( $str ) ); __END__ [ "listliteral", [ "ListLiteral", [ "../classSPL_1_1Operator_1_1Instance_1_1ExpressionTree_1_1ListLi +teral.html", 1, "SPL::Operator::Instance::ExpressionTree", ], ], ]
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: using Text::Balanced (JSON)
by slugger415 (Monk) on Jan 31, 2014 at 15:01 UTC |