in reply to If/else within a foreach loop to check strings within an array
Whilst for the very short input in your example choroba's solution is perfectly fine, for real sequences which are typically very large, spliting the sequence to an array of scalars each holding a single char and then processing them one at a time is grossly inefficient. Of both time and memory.
Far more efficient for your stated purpose is to process the sequence as a string:
my $dna_input = $ARGV[0]; print "Non-nucleotide '$1' at posn %d\n", $-[0] while $dna_input =~ m[ +([^acgt])]g;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: If/else within a foreach loop to check strings within an array
by LanX (Saint) on Oct 19, 2013 at 22:47 UTC | |
by BrowserUk (Patriarch) on Oct 19, 2013 at 23:01 UTC |