- Data::Dumper
Debugging (pretty printing)
But once we have those references we have a better tool to print out their content.
examples/references/dump_content.pl
#!/usr/bin/env perl use strict; use warnings; use Data::Dumper qw(Dumper); my @names = qw(Foo Bar Baz); my $names_ref = \@names; my %phones = ( Foo => 123, Bar => 456, Baz => 789, ); my $phones_ref = \%phones; print Dumper $names_ref, $phones_ref;
$VAR1 = [
'Foo',
'Bar',
'Baz'
];
$VAR2 = {
'Bar' => 456,
'Baz' => 789,
'Foo' => 123
};
Actually you can use the Dumper on the references themself without putting them in scalar variables.
print Dumper \@names, \%phones;