... my $bad_count = 0; while (<...>) { chomp; my ( $name, $seq ) = split; unless ( $seq and $seq =~ /^[ACGT]+$/ ) { $bad_count++; next; } ... } warn "Input file had $bad_count unusable lines\n"; ...