print FILEHANDLE LIST
Thx haukex for the precise explanation. I like to finish my threads with working code, for myself and presumably others who will search the net for why Data::Dumper doesn't work unless you 'use' it. They give a pretty good example here, and I wish that all modules would give example code snippets:
$ ./1.dd.pl
$VAR1 = [
{
'81' => 'QQQ',
'80' => 'PPP',
'79' => 'OOO',
'78' => 'NNN',
'77' => 'MMM',
'76' => 'LLL',
'75' => 'KKK',
'74' => 'JJJ',
'73' => 'III'
},
{
'75' => 'KKK',
'79' => 'OOO',
'77' => 'MMM',
'81' => 'QQQ',
'73' => 'III'
},
{
'III' => '73',
'JJJ' => '74',
'KKK' => '75',
'LLL' => '76',
'MMM' => '77',
'NNN' => '78',
'OOO' => '79',
'PPP' => '80',
'QQQ' => '81'
}
];
$ cat 1.dd.pl
#!/usr/bin/perl -w
use 5.011;
use Data::Dumper;
$Data::Dumper::Sortkeys = \&my_filter;
my $foo = { map { (ord, "$_$_$_") } 'I'..'Q' };
my $bar = { %$foo };
my $baz = { reverse %$foo };
print Dumper [ $foo, $bar, $baz ];
sub my_filter {
my ($hash) = @_;
# return an array ref containing the hash keys to dump
# in the order that you want them to be dumped
return [
# Sort the keys of %$foo in reverse numeric order
$hash eq $foo ? (sort {$b <=> $a} keys %$hash) :
# Only dump the odd number keys of %$bar
$hash eq $bar ? (grep {$_ % 2} keys %$hash) :
# Sort keys in default order for all other hashes
(sort keys %$hash)
];
}
$
|