#!/usr/bin/perl -w # This script will ask for the name of a file # containing DNA sequence and validate each # line of sequence. If invalid bases are found, # the offending line number(s) are reported. # Author: MyName # Version 1.2 21 Feb 04 added line number output # Version 1.1 24 Dec 03 output invalid base # Version 1.0 15 Sep 03 initial version use strict; my ($filename, $line, $lnum); # Notice that when we print a question we do # not include a newline since we want the user's # typed response to be entered on the same line print "Enter DNA sequence file name: "; $filename = ; # Open the file, or die with an error message open(SEQFIL, "$filename") or die "Cannot open file $filename\n"; # Count line numbers for error reporting $lnum = 0; while ( $line = ) { $lnum++;; chomp($line); if ( $line =~ /([^ACGTacgt])/ ) { print "Invalid DNA sequence ($1) on line $lnum\n"; } } # end of while close SEQFIL;