use strict; use warnings; use Data::Dumper; # Data infered from posted output. my @xfeld = qw(0 0 y y 0 5 x 5 5 y); my @xfix = qw( UNKNOWN_x_0 UNKNOWN_x_1 UNKNOWN_x_2 3.640250E-4 ); my @yfix = qw( UNKNOWN_y_0 UNKNOWN_y_1 UNKNOWN_y_2 3.640000E-4 ); my @fnfeld = ( {fn => 'UNKNOWN_n_0',}, {fn => 'UNKNOWN_n_1',}, {fn => 'UNKNOWN_n_2',}, {fn => 'UNKNOWN_n_3',}, {fn => 'UNKNOWN_n_4',}, {fn => 'UNKNOWN_n_5',}, {fn => 'UNKNOWN_n_6',}, {fn => 'UNKNOWN_n_7',}, {fn => 'UNKNOWN_n_8',}, {fn => 'UNKNOWN_n_9',}, ); my @yfeld; $#yfeld = $#xfeld; my %plotx; my $ii = -1; for (my $i = 0; $i <= $#yfeld; $i++) { $ii = $ii + 1; print "$i $ii "; if ($xfeld[$i] eq 'x') { push @{$plotx{$ii}}, @xfix; print "x\n"; } elsif ($xfeld[$i] eq 'y') { push @{$plotx{$ii}}, @yfix; print "y\n"; } else { push @{$plotx{$ii}}, $fnfeld[$xfeld[$i]]->{'fn'}; # The Previous statement stores only one value. # The failing prints expects at least four. print "$xfeld[$i]\n"; } } print "\n"; print "2 $plotx{2}[3]\n"; print "3 $plotx{3}[3]\n"; print "5 $plotx{5}[3]\n"; # Array element does not exist print "6 $plotx{6}[3]\n"; print "7 $plotx{7}[3]\n"; # Array element does not exist print "8 $plotx{8}[3]\n"; # Array element does not exist print "9 $plotx{9}[3]\n"; print Dumper(\%plotx); OUTPUT: 0 0 0 1 1 0 2 2 y 3 3 y 4 4 0 5 5 5 6 6 x 7 7 5 8 8 5 9 9 y 2 3.640000E-4 3 3.640000E-4 Use of uninitialized value in concatenation (.) or string at buchi2.pl line 41. 5 6 3.640250E-4 Use of uninitialized value in concatenation (.) or string at buchi2.pl line 43. 7 Use of uninitialized value in concatenation (.) or string at buchi2.pl line 44. 8 9 3.640000E-4 $VAR1 = { '1' => [ 'UNKNOWN_n_0' ], '8' => [ 'UNKNOWN_n_5' ], '6' => [ 'UNKNOWN_x_0', 'UNKNOWN_x_1', 'UNKNOWN_x_2', '3.640250E-4' ], '3' => [ 'UNKNOWN_y_0', 'UNKNOWN_y_1', 'UNKNOWN_y_2', '3.640000E-4' ], '2' => [ 'UNKNOWN_y_0', 'UNKNOWN_y_1', 'UNKNOWN_y_2', '3.640000E-4' ], '9' => [ 'UNKNOWN_y_0', 'UNKNOWN_y_1', 'UNKNOWN_y_2', '3.640000E-4' ], '7' => [ 'UNKNOWN_n_5' ], '5' => [ 'UNKNOWN_n_5' ], '0' => [ 'UNKNOWN_n_0' ], '4' => [ 'UNKNOWN_n_0' ] };