in reply to Pretty Printing with Data::Dumper
If you open up the source code, you see two places that determines this:
$Indent = 2 unless defined $Indent;
And
if ($Indent > 0) { $s->{xpad} = " "; $s->{sep} = "\n"; }
$s->{sep} is where that line break comes from. If you change $s->{sep} to "". You got this:
$VAR1 = [ 'a', 'b', 'c' ];
The line break is gone, but you got whole bunch of blanks. Those blanks are caused by the Indent. So change Indent to 0. Now you get:
$VAR1 = ['a','b','c'];
That's what you asked for. But with setting Indent to 0, is it still needed to set $s->{"sep"} to ""? No, as that block will only be executed if Indent is greater than 0, which is no longer true. So the only thing you need to do is to set Indent to 0.
Do you need to change the source code? No, You can set Indent from your program as Ovid has showed you.
use Data::Dumper; use strict; use warnings; $Data::Dumper::Indent = 0; my $a = ["a", "b", "c"]; print Dumper($a);
In Section
Seekers of Perl Wisdom