in reply to Array looping
Rather than walking the arrays, use join and xor the joined strings, counting nuls with tr.
johngg@shiraz:~/perl/Monks > perl -Mstrict -Mwarnings -E ' my @arr1 = qw{ A T C G T C G A G C G }; my @arr2 = qw{ A C G T C C T G T C G }; my $count = ( ( join q{}, @arr1 ) ^ ( join q{}, @arr2 ) ) =~ tr{\0}{}; say $count;' 4
I hope this is of interest.
Cheers,
JohnGG
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Array looping
by vrk (Chaplain) on Apr 12, 2017 at 15:01 UTC | |
by johngg (Canon) on Apr 12, 2017 at 16:53 UTC | |
by vrk (Chaplain) on Apr 13, 2017 at 08:11 UTC | |
by Anonymous Monk on Apr 12, 2017 at 22:42 UTC | |
by vrk (Chaplain) on Apr 13, 2017 at 08:12 UTC | |
by james28909 (Deacon) on Apr 13, 2017 at 11:55 UTC | |
by afoken (Chancellor) on Apr 13, 2017 at 14:16 UTC |
In Section
Seekers of Perl Wisdom