i need to have all 2 alphabets or 3 alphabets words
You can call substr() repeatedly in a loop (as Ratazong pointed out), which gives you all 2/3/...-substrings.
I'm not 100% sure what your task is, but judging from the sample output, you seem to want something like this:
my $s = "AACCCDGYAEELPSWWYAOOLLLSSBBBDDD";
for my $len (2..4) {
my @parts;
for my $offs (0..length($s)-$len) {
push @parts, substr($s, $offs, $len);
}
print "i=$len: @parts\n";
}
__END__
i=2: AA AC CC CC CD DG GY YA AE EE EL LP PS SW WW WY YA AO OO OL LL LL
+ LS SS SB BB BB BD DD DD
i=3: AAC ACC CCC CCD CDG DGY GYA YAE AEE EEL ELP LPS PSW SWW WWY WYA Y
+AO AOO OOL OLL LLL LLS LSS SSB SBB BBB BBD BDD DDD
i=4: AACC ACCC CCCD CCDG CDGY DGYA GYAE YAEE AEEL EELP ELPS LPSW PSWW
+SWWY WWYA WYAO YAOO AOOL OOLL OLLL LLLS LLSS LSSB SSBB SBBB BBBD BBDD
+ BDDD
|