I'm having loads of fun with perl on Pocket_PC from General Paranoyaxc Software and the PerlIDE there too. Of course, Perl is stripped a bit bare for the environment. One of the things I was wanting was Data::Dumper. Silly me, I thot, "Why not write a dumbed down version that's perl only." Trouble is, I couldn't figure how to generically de-ref a blessed object. This is probably impossible? I'm assuming no use strict.
# NOTE: THIS IS BUSTED, but interesting... sub DDumper { my($v,$i)=@_; # v=what we're dumping, i=indent $i="\n" unless $i; $i.=' '; my $r=ref($v); my $s=''; # s is the string we'll return when done if($r eq HASH) { $s.= "{ "; for (keys %$v) { $s.= Dumper($_,$i)." => ".Dumper($v->{$_},$i).",$i"; } $s.= " }$i"; } elsif($r eq ARRAY) { $s.= "[ "; for ( @$v) { $s.= Dumper($_,$i).",$i"; } $s.= " ]$i"; } elsif($r) { $s.= "bless( ".Dumper(%{$v},$i).", '$r') $i"; } else { $s.= "'$v' "; } $s; }
For discussion sake, let's assume all blessed objects are hashes. Does that help?

This snippit recurses endlessly on blessed objects (I think) and has the curious property of doubling square brackets and doing goofy things with quotes and commas in hashes.

Well, it was an interesting recursive diversion...

j


In reply to Data::Dumper in perl-only? by jhanna

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.