Another way could be to use Tie::File and grep.
use strict; use warnings; use Tie::File; die "File does not exist" unless -f $ARGV[0]; tie my @file, 'Tie::File', $ARGV[0] or die "Could not tie file"; if ( grep !/^[actg]+$/i, @file ) { print "BAD\n"; } else { print "OK\n"; }
Update: Inefficent see below update by ikegami
In reply to Re: =~ matches non-existent symbols
by rnewsham
in thread =~ matches non-existent symbols
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |