#!/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,
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|