Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: using Text::Balanced (JSON)

by Anonymous Monk
on Jan 31, 2014 at 00:15 UTC ( [id://1072753]=note: print w/replies, xml ) Need Help??


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
    very nice, thank you!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2024-04-25 08:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found