Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Now I understand why jesuashok is asking this question!  He has run into the EXACT same problem as Eric Joanis did on this perl5 porter newsgroup submission (but written over 4 years ago, on March 2, 2002).

And by "EXACT", I mean word-for-word the same:

----------------------------------------------------------------- [Please enter your report here] I have encountered a situation where the output of Data::Dumper cannot + be incorporated in a script to restore the original data, specifically wh +ere a string contains the sequence ^M^J and $Useqq is unset. Please find attached a script which illustrates the problem. (Note: this arises +in my work because I have packed numbers in a large data structure, and o +n a few occasions the packed sequence happens to include ^M^J as a subsequence.) The issue arises because perl seems to have a "friendly" way to handle + DOS files on Unix platforms. My guess is that at a really early stage of reading the script file, ^M^J is translated to ^J, presumably before p +erl is even parsing the input. Obviously, it is ignoring the single quote +s in this example, since the single quotes should suppress any interpretati +on of the input. (Note that I realize this is generally a desirable behaviour, so I think the bug is with Data::Dumper, not with how files + are read.) Note also that, as my script shows, this is not a problem when we use +eval on the output of dump, but only when the code is saved to a file a compiled back from the file. (Unfortunately for me, I wish to save th +e dump to a file for frequent reuse, so that doesn't help me much...) An obvious solution is to set $Useqq to 1, but it seems to me this mod +ule ought to output correct code in all cases, so I'm still submitting thi +s as a bug report. A somewhat ugly solution is to use something like this: Replace 'stuff^M^Jmorestuff' by 'stuff' . "\r\n" . 'morestuff' I don't really like it, but I can't think of any other way to get arou +nd the fact that single quotes don't permit any escape sequences (other t +han \\ and \'). Here is the script I wrote to illustrate the problem: #!/pkgs/perl-5.006/bin/sparc-sun-solaris2.5.1/perl -w # This short script illustrates a bug with Data::Dumper, where it will # create code that does not correctly reconstruct the data structure # dumped when copied into source code. use Data::Dumper; $Data::Dumper::Purity = 1; # This makes no difference my $a = "\x0d\x0a"; print "Initial length: ", length($a), "\n"; my $dump = Data::Dumper->Dump([$a], [qw(a)]); print "Dumped code with Useqq = 0:\n", $dump; eval $dump; print "New length after eval: ", length($a), "\n"; $Data::Dumper::Useqq = 1; $dump = Data::Dumper->Dump([$a], [qw(a)]); print "Dumped code with Useqq = 1:\n", $dump; eval $dump; print "New length after eval: ", length($a), "\n"; # This is dump's output when $Useqq = 0. -- Doesn't work! $a = ' '; print "New length after dumped code (with Useqq = 0): ", length($a), " +\n"; # This is dump's output when $Useqq = 1. -- Works correctly $a = "\r\n"; print "New length after dumped code (with Useqq = 1): ", length($a), " +\n"; [Please do not change anything below this line] -----------------------------------------------------------------

For more information about jesuashok's habit of wholesale "borrowing" of material from other websites, please refer to this node.


In reply to Re: Data::Dumper issue = PLAGIARISM by liverpole
in thread Data::Dumper issue by jesuashok

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, 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, 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.
  • Log In?

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

    How do I use this? | Other CB clients
    Other Users?
    Others making s'mores by the fire in the courtyard of the Monastery: (6)
    As of 2020-06-01 14:34 GMT
    Find Nodes?
      Voting Booth?
      Do you really want to know if there is extraterrestrial life?

      Results (2 votes). Check out past polls.