#!/usr/bin/env perl # https://www.perlmonks.org/?node_id=11113020 use Data::Dumper; $Data::Dumper::Sortkeys=1; # make it easier to find "things" in the "dumps" # Yes we'll take all the help we can get use strict; use warnings; # Read the data one line at a time while () { # Same as while ($_=) { # And get rid of the $INPUT_LINE_SEPARATOR (\n); chomp; # Same as chomp($_); warn Data::Dumper->Dump([\$_],[qw(*_)]),' '; # Let's see what we have ... there shouldn't be a trailing \n (my $bad=$_)=~ tr/[ATCG]/ /; warn Data::Dumper->Dump([\$_],[qw(*_)]),' '; # So all the valid ones are gone if ($bad !~ m{^\s+$}) { # Are there any bad ones? print "line: $.\n" # Yes - so print the offending line number print "$_\n"; # The offending line print "$bad\n"; # The offending character(s) in the line $bad=~ s{\w}{print 1+pos($bad),','}eg; # Look for a "character" if you find one print its "location' print "\n"; }; }; __END__ TAAGAACAATAAGAACAA TAAGAACAATAAUAACAA TAYGAACAkTAAGAACzz