in reply to List comparison problem

The problem is in the postfix increment operation.

$H_count ++ and print ' On List H' if exists $H_list{$_};

Use an if block (or similar) instead to avoid conditional dependence on $H_count under the increment operator. Others will be able able to explain the reasons in detail.

use strict; use warnings; my %H_list; open my $H_list, '<', 'listH.txt' or die "Cannot open listH.txt: $!"; + while (my $line = <$H_list>) { chomp $line; $line =~ s/\r//g; # removes windows CR characters $line =~ s/\s+$//; # removes trailing white spaces $H_list{$line} = 1 } close $H_list; my ($L_count, $H_count); open my $L_list, '<', 'listL.txt' or die "Cannot open listL.txt: $!"; + while (<$L_list>) { chomp; s/\r//; s/\s+$//; $L_count ++; print; if (exists $H_list{$_}) { $H_count ++; print ' On List H'; } print "\n"; } print "List L UNIQUES: $L_count; FLAGGED From List H: $H_count \n";

UPDATE: See for example node 776720.