in reply to String/Integer Concatenation

Another way to do it - avoid all that fiddly substr stuff:

use strict; use warnings; print comNucCount('acgtacgtacgtacgt', 'aaaaccccggggtttt'), "\n"; sub comNucCount { my @str1 = split '', lc shift; my @str2 = split '', lc shift; my %counts = (a => 0, c => 0, g => 0, t => 0); for (@str1) { last if ! @str2; # Length mismatch - done $counts{$_}++ if $_ eq shift @str2; } return "A=$counts{'a'}, C=$counts{'c'}, G=$counts{'g'}, T=$counts{ +'t'}"; }

Prints:

A=1, C=1, G=1, T=1

DWIM is Perl's answer to Gödel