buchi2 has asked for the wisdom of the Perl Monks concerning the following question:
In article 1195995 I got it work with your help to build
an array of hashes.
Now I want to get out a whole array of it, but it is always
empty.
What is going wrong with it?#!/usr/bin/perl -w use strict; use warnings; 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 "array $array[3]\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; }
Regards, Buchi
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: How to get out an array of a hash?
by shmem (Chancellor) on Aug 03, 2017 at 09:02 UTC | |
Re: How to get out an array of a hash? (Updated)
by thanos1983 (Parson) on Aug 03, 2017 at 08:21 UTC | |
Re: How to get out an array of a hash?
by hexcoder (Curate) on Aug 03, 2017 at 08:25 UTC | |
Re: How to get out an array of a hash?
by Anonymous Monk on Aug 03, 2017 at 09:20 UTC |