Output:use strict; use warnings; my $array = [ { 'name' => 'Discount', 'reference' => '100 ', 'type' => 'Paper' }, { 'name' => 'Documents', 'reference' => '100 ', 'type' => 'Paper' }, { 'name' => 'Money', 'reference' => '340 ', 'type' => 'Plastic' }, { 'name' => 'State', 'reference' => '40 ', 'type' => 'Cotton' }, { 'name' => 'Slice', 'reference' => '30 ', 'type' => 'Cotton' }, { 'name' => 'Part', 'reference' => '45 ', 'type' => 'Cotton' }, ]; my %hash; $hash{$_->{'type'}}{$_->{'name'}} = $_->{'reference'} for @$array; print "Results:\n"; for my $k1 (sort keys %hash) { print " $k1:\n"; for my $k2 (sort keys %{$hash{$k1}}) { print " $k2 - $hash{$k1}{$k2}\n"; } }
Results: Cotton: Part - 45 Slice - 30 State - 40 Paper: Discount - 100 Documents - 100 Plastic: Money - 340
In reply to Re: Accessing this array ref.
by TJPride
in thread Accessing this array ref.
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |