in reply to use of uninitialized value in array

Tip #2 from the Basic debugging checklist: print. Add more prints inside your for loop. It is likely that $a is beyond the last element of the @matching_values array.

for($a=0;$a<=scalar(@hfr);$a++) { my @matching_indices=indexes {$hfr[$a]}@gl; my @matching_values=@gl[@matching_indices]; print "a=$a\n"; use Data::Dumper; print Dumper(\@matching_indices); print "$matching_indices[$a]"; }

Replies are listed 'Best First'.
Re^2: use of uninitialized value in array
by hippo (Archbishop) on Aug 02, 2013 at 17:19 UTC

    $a is definitely going beyond the end of @hfr. Use < instead of <= in the loop test to avoid this.

    Oh, and don't use $a as a variable name. Nor $b for that matter.

    Update: For some reason I had missed that Cristoforo had already mentioned this. Sorry for the waste of bandwidth.

Re^2: use of uninitialized value in array
by rocketperl (Sexton) on Aug 02, 2013 at 16:14 UTC
    Thanks for your help. Will go through the tutorials. but i still get the same error with your idea too. anyway will see if i get any help in the tutorials.