Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Sure, why not :) I did it long before crockford published JSON, long before anyone was using "AJAX" and there was a jQuery, when we called it DHTML :)

#!/usr/bin/perl -- ## ## ## perltidy -olq -csc -csci=3 -cscl="sub : BEGIN END if " -otr -opr - +ce -nibc -i=4 -pt=0 "-nsak=*" #!/usr/bin/perl -- use strict; use warnings; use Data::Dump qw/ dd pp /; use Data::Dumper(); use Safe; my $futz = do { my %ro = 1 .. 2; my %sham = 3 .. 4; my %bo = ( a => \%ro, b => \%ro, c => \%sham ); \%bo; }; ddd( $futz ); ddd( SafestUndumper( ppp( $futz ) ) ); dd( $futz ); dd( SafestUndumper( pp( $futz ) ) ); exit( 0 ); sub ppp { use Data::Dumper(); return Data::Dumper->new( [@_] )->Sortkeys( 1 )->Purity( 1 )->Inde +nt( 0 ) ->Useqq( 1 )->Dump . '$VAR1;'; } ## end sub ppp sub ddd { print ppp( @_ ), "\n"; } ## end sub ddd sub SafestUndumper { use Safe; my $s = Safe->new; # http://perl5.git.perl.org/perl.git/blob?f=regen/opcodes $s->permit_only( "anonlist", "anonhash", "pushmark", # perlcall says "PUSHMARK macro tells Perl to make a mental note of th +e current stack pointer." "const", "undef", "list", "lineseq", "padany", "leaveeval", # needed for Safe to operate, is safe without +entereval # needed for self-referentialnes "sassign", "rv2sv", "rv2hv", "helem", # dd-style do-block self-referentialnes "enter", "null", ); $s->reval( @_ ); } ## end sub SafestUndumper __END__ $VAR1 = {"a" => {1 => 2},"b" => {},"c" => {3 => 4}};$VAR1->{"b"} = $VA +R1->{"a"};$VAR1; $VAR1 = {"a" => {1 => 2},"b" => {},"c" => {3 => 4}};$VAR1->{"b"} = $VA +R1->{"a"};$VAR1; do { my $a = { a => { 1 => 2 }, b => 'fix', c => { 3 => 4 } }; $a->{b} = $a->{a}; $a; } do { my $a = { a => { 1 => 2 }, b => 'fix', c => { 3 => 4 } }; $a->{b} = $a->{a}; $a; }

In reply to Re: Perl data notation (PSON/JSON/SafestUndumper) by Anonymous Monk
in thread Perl data notation by rje

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

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

    No recent polls found