Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I basically used the above concept and never able to print accordingly. Usually just prints out stufff like "HASH(0xb5a3c)" etc.my %hash; my @array; my $n = 1; $hash{"one$n") = "hi"; $n++; $hash{"one$n") = "hi 2 you too"; push @array, \%hash; my $n = 1; $hash{"two$n") = "hello"; $n++; $hash{"two$n") = "hello 2 you too"; push @array, \%hash; some_routine($n, \%some_other_hash, \@array); sub some_routine { #$n, and $h are other variables that may be passed to this routine. my ($n, $h, $array_of_hashes) = @_; foreach my $d (@{$array_of_hashes}) { print $d[0]{'one1'}; } #...also tried this... print $array_of_hashes[0]{'one1'}; print $array_of_hashes[0]{'one2'}; print $array_of_hashes[1]{'two1'}; print $array_of_hashes[1]{'two2'}; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Passing an array of hashes to a subroutine
by ikegami (Patriarch) on May 21, 2007 at 05:54 UTC | |
by blazar (Canon) on May 21, 2007 at 22:01 UTC | |
by ikegami (Patriarch) on May 22, 2007 at 05:29 UTC | |
by blazar (Canon) on May 22, 2007 at 10:19 UTC | |
|
Re: Passing an array of hashes to a subroutine
by NetWallah (Canon) on May 21, 2007 at 05:59 UTC | |
|
Re: Passing an array of hashes to a subroutine
by perleager (Pilgrim) on May 21, 2007 at 06:27 UTC |