in reply to Re^4: to loop through an array
in thread to loop through an array and store each of the subtotals in the elements of another array

I am not sure I fully understand the data that is being printed. print "$element\t=>$count{$element}\n"; I seem to getting a strange error Use of uninitialized value in concatenation (.) or string at searchfile.pl line 91, <FILE> line 1023078. Is there a problem with the hash and how its counting the elements

Replies are listed 'Best First'.
Re^6: to loop through an array
by kennethk (Abbot) on May 16, 2011 at 14:11 UTC
    There are two possibilities I see here. First, you may not be assigning anything to $_. If you are not getting any numerical output, this is your issue.

    Second, if not every key gets hit, then some elements will never be initialized. You can fix this either by initializing all elements in %count to zero before the loop ($count{$_} = 0 for @findle;) or limit your output to cycling over keys where you got hits:

    for my $element (sort keys %count) { print "$element\t=>$count{$element}\n"; }