in reply to Custom HOA printing
As you're just new with hashes of arrays (and presumably other complex data structures) you should find Data::Dumper helps you to A) define data structures in one hit and B) clearly see what your data structure contains:
(note the backslash in front of the % in the print statement) which would give you:#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my %hash; push @{$hash{"3"}}, "apple"; push @{$hash{"2"}}, "pear"; push @{$hash{"5"}}, "orange"; push @{$hash{"3"}}, "grape"; push @{$hash{"2"}}, "icky pineapple"; print Dumper(\%hash), $/;
Just change the $VAR1 to %hash and the {} to () and it's done for you :o)$VAR1 = { '3' => [ 'apple', 'grape' ], '2' => [ 'pear', 'icky pineapple' ], '5' => [ 'orange' ] };
my %hash = ( '3' => [ 'apple', 'grape' ], '2' => [ 'pear', 'icky pineapple' ], '5' => [ 'orange' ] );
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Custom HOA printing
by McDarren (Abbot) on Jan 29, 2006 at 00:37 UTC |
In Section
Seekers of Perl Wisdom