open (INFILE, $ARGV[0]) or die "unable to open file: $!"; # It's a good idea to check the error message in Perl's special variable $! my ($a_count, $c_count, $g_count, $t_count, $err_count) = 0; while ( ) { s/^>genome//; s/\s//g; $a_count += tr /[Aa]//; $c_count += tr /[Cc]//; $g_count += tr /[Gg]//; $t_count += tr /[Tt]//; $err_count += tr /[ACGTacgt]//c; } print "As: $a_count\n", "Cs: $c_count\n", "Gs: $g_count\n", "Ts: $t_count\n", "Errors: $err_count\n";