Hi pg,

Im afraid you seem to have made an invalid assumption here:

print Dumper($hash); #which prints (\\d+), this really confused me

Dumper doesnt print (\\d+) it prints '(\\d+)' which is perfectly correct. Dumpers output (with any settings but Terse) is as merlyn pointed out meant to be evalled. This means that it emits valid perl statements to reconstruct the original data. So when it outputs a single quoted string it of course emits \\ instead of \ just as you used \\ inside of the doublequoted string when you assigned the value in the first place.

Short of emitting HERE docs as part of its output (which would be a PIA to read IMO) there is no way for it to specify a \ inside of a quoted construct except as \\. (Well, thats not strictly true. Dumper could be smarter about knowing which \ sequnces actually need to be doubled, but IMO the output would look even stranger, with some \ doubled and some not.)

The moral of the story is that Dumper does indeed get stuff wrong, but those things are rare indeed, and most of them are well known to the author and maintainers and to most of the more experienced members of the Perl community. It is unlikely that you will encounter a Dumper bug that isnt on this list. And incidentlly for the few things that do remain, they havent been fixed becuase currently it doesnt look like they are worth being fixed.

#are these the same or different? my ($x,$y); $x=\$y; $y=\$x; print Dumper([$x,$y]); my $ar=[]; $ar->[0]=\$ar->[1]; $ar->[1]=\$ar->[0]; print Dumper($ar);
HTH

--- demerphq
my friends call me, usually because I'm late....


In reply to Re: Data::Dumper style by demerphq
in thread Data::Dumper style by pg

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.