my @old_stock1 = ('products','here'); my @old_stock2 = ('products','here'); # define hash to store quantities my %new_stock; # iterate through old for (@old_stock1, @old_stock2) { # add one to count for this element # (creating it if it doesn't exist) $new_stock{$_}++; } #### for (keys %new_stock) { print "$_ = $new_stock{$_}\n"; }