http://qs321.pair.com?node_id=11113031


in reply to Find element in array

#!/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 (<DATA>) { # Same as while +($_=<DATA>) { # 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 val +id 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 "ch +aracter" if you find one print its "location' print "\n"; }; }; __END__ TAAGAACAATAAGAACAA TAAGAACAATAAUAACAA TAYGAACAkTAAGAACzz

Yields

perl 3020a.pl 2> nul TAAGAACAATAAUAACAA U 13, TAYGAACAkTAAGAACzz Y k zz 3,9,17,18,