#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} } }