open (my $FALSEF, "<", "FalseFriendsList.txt"); #### my %ExistingFalseFriend; # or my %existing_false_friend; # or my %Existing_False_Friend; #### my $Debug = 3; # 0 - production, 1 - minor debugging, 2 .. 9 for different levels #### #while the FF input exists while (my $line = ) { # chomp off the new line chomp $line; # chomp could be part of while statement # increment $line $falsef{$line}++; } ### Now during debugging print to open log file if ( $Debug ) # this could be 'if ( 1==1 )' for testing, your call { foreach my $key ( sort keys $falsef ) { print $LOG "$key\t$falsef{$key} } }