in reply to How to get out an array of a hash?

Hello buchi2,

You are getting an array of arrays, I have altered the output so you can see it easier.

#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my %hierhash; my @feld; my @hashfeld; my $wert; my @array; @hashfeld = (); %hierhash = &dofn(0,5,1); print "1 $hierhash{'var2'}[3] \n"; push @hashfeld, {%hierhash}; %hierhash = &dofn(0,5,2); print "2 $hierhash{'var2'}[3] \n"; push @hashfeld, {%hierhash}; $wert = $hashfeld[0]->{'var2'}[3]; print "$wert\n"; $wert = $hashfeld[1]->{'var2'}[3]; print "$wert\n"; @array = (); @array = $hashfeld[1]->{'var2'}; print Dumper \@array; print "array $array[0][0]\n"; # ################################################ # holt die fn Werte # ################################################ sub dofn { my $i; my ($ivon, $ibis, $imal) = @_; my %hashfn; for ($i = $ivon; $i < $ibis; $i++) { push @{$hashfn{'var1'}}, $i*$imal; push @{$hashfn{'var2'}}, $i*$imal*10.; push @{$hashfn{'var3'}}, $i*$imal*20.; } return %hashfn; } __END__ $ perl test.pl 1 30 2 60 30 60 $VAR1 = [ [ 0, 20, 40, 60, 80 ] ]; array 0

From there it is easy (I guess) on how to get the array or at least you can search online on how to extract an array from an array of arrays ;)

A few minor recommendations regarding your code (very briefly). You do not need to add the -w on the shebang, -w it is an alternative of using use warnings;. Also you do not need to use the & on your subroutines see here why What is the point of the & / ampersand sigil for function refs?.

Update: I used Data::Dumper to debug the output, I think you will find it extremely useful, at least I do. :)

Update2: Fellow monk hexcoder provided you already an answer to your question so I thought it would be nice also to add some minor notes on your code. In Perl you do not need to predefine your variables you can define them the moment you assign them. Also I found very useful the feature say. It is like print but it add an new line character \n at the end your string or what ever attribute you are calling.

#!/usr/bin/perl use strict; use warnings; use Data::Dumper; use feature 'say'; my %hierhash = dofn(0,5,1); say "1 $hierhash{'var2'}[3]"; push my @hashfeld, {%hierhash}; %hierhash = dofn(0,5,2); say "2 $hierhash{'var2'}[3]"; push @hashfeld, {%hierhash}; my $wert = $hashfeld[0]->{'var2'}[3]; say $wert; $wert = $hashfeld[1]->{'var2'}[3]; say $wert; # @array = $hashfeld[1]->{'var2'}; my @array = @{$hashfeld[1]->{'var2'}}; print Dumper \@array; # ################################################ # holt die fn Werte # ################################################ sub dofn { my $i; my ($ivon, $ibis, $imal) = @_; my %hashfn; for ($i = $ivon; $i < $ibis; $i++) { push @{$hashfn{'var1'}}, $i*$imal; push @{$hashfn{'var2'}}, $i*$imal*10.; push @{$hashfn{'var3'}}, $i*$imal*20.; } return %hashfn; } __END__ $ perl test.pl 1 30 2 60 30 60 $VAR1 = [ 0, 20, 40, 60, 80 ];

Update3: One more reference to read from a similar question Dereference array of arrays.

Hope this helps, BR.

Seeking for Perl wisdom...on the process of learning...not there...yet!