develooper Front page | perl.perl5.porters | Postings from April 2008

Re: [perl #43617] [RESOLVED] Data::Dumper ignores ^M in scalars?

Thread Previous
April 28, 2008 01:04
Re: [perl #43617] [RESOLVED] Data::Dumper ignores ^M in scalars?
Message ID:
On Mon, 28 Apr 2008 00:18:28 +0200, Daniel Hagerty <>  

>     Apologies on not having responded earlier, I probably missed the
> response.

Thank you for replying.

>     FWIW, useqq now produces expected results; usage without useqq
> continues to produce an empty string.


use Data::Dumper;
print Dumper("a\rb");

Does it produce an empty string or do you see - in the shell - something  
like:  b';R1 = 'a'
Or using | od -tx1: 0000000 24 56 41 52 31 20 3d 20 27 61 0d 62 27 3b 0a
(a = 61, \r = 0d, b = 62)

> Tried this with perl 5.8.8 w/
> Data::Dumper 2.121_08 on both netbsd 4.0 and debian 4.0 systems.
>     If one is to believe that Data::Dumper's intent is to produce a
> string that can be eval'd to produce a copy of the original object
> like it's manual page indicates, this appears to be a bug.

Actually, it can be eval'ed without a problem.
You can even write it in a file, read that file and eval it.

What you can not do is copy the output from the shell/console, paste it in  
another file and eval that.
The handling of  ^M (or \r) is seen by the shell (or atleast I think) as a  
way how to control the display of the output.
The same is true for ANSI escapes. (if your  
shel/terminal/console/display/... supports them)

This is because the shell/console reads them and changes the text that is  
If you do not want the shell to do that then you can set  $Useqq = 1   
which prevents them from being outputted.

In all, I do not think this is a bug.

Try for example:


use Data::Dumper;
my $foo = Dumper("a\rb");
print "Foo = $foo";
eval $foo;

$Data::Dumper::Useqq = 1;
print "eval \$foo = " . Dumper($VAR1);
$VAR1 = "";

my $fn = "/tmp/foo_$$_" . time;
open my $fh, ">", $fn or die "Can't open file $fn: $!";
print $fh $foo;
close $fh;

require $fn;
unlink $fn;
print "require $fn = " . Dumper($VAR1);
$VAR1 = "";


I hope you now agree with me that it is not a bug.

Kind regards,


Thread Previous Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About