Hi All, I was trying to generate variations of the 8 character string
"AAAAAAAA" by changing every character with the elements containing in
an array @aa = ('A', 'B', 'C', 'D'). The way I did it was quite naive,
using a "for" loop that changes the A character at position 1 of the
AAAAAAAA string by all the characters in the @array, and repeating
the for loop to change the remaining positions. Thus, I have 8 for
loops in my code, and wonder how I can achieve the same whithout having
to write 8 times the for loop. The actual code I am using is attached
bellow. Any suggestion will be welcomed, and thanks in advance for the
help.
Cheers
#!/usr/sbin/perl -w
use strict;
my @aa =
('A','C','D','E','F','G','H','I','K','L','M','N','P','Q','R','S','T','V','W','Y');
my $i;
my $l;
$l = @aa;
$l = $l -1;
for ($i= 0; $i <= $l; $i++) {
printf "%3s %8s\n", "p1$aa[$i]", "$aa[$i]AAAAAAA";
}
for ($i= 1; $i <= $l; $i++) {
printf "%3s %8s\n", "p2$aa[$i]", "A$aa[$i]AAAAAA";
}
for ($i= 1; $i <= $l; $i++) {
printf "%3s %8s\n", "p3$aa[$i]", "AA$aa[$i]AAAAA";
}
for ($i= 1; $i <= $l; $i++) {
printf "%3s %8s\n", "p4$aa[$i]", "AAA$aa[$i]AAAA";
}
#
for ($i= 1; $i <= $l; $i++) {
printf "%3s %8s\n", "p5$aa[$i]", "AAAA$aa[$i]AAA";
}
for ($i= 1; $i <= $l; $i++) {
printf "%3s %8s\n", "p6$aa[$i]", "AAAAA$aa[$i]AA";
}
for ($i= 1; $i <= $l; $i++) {
printf "%3s %8s\n", "p7$aa[$i]", "AAAAAA$aa[$i]A";
}
for ($i= 1; $i <= $l; $i++) {
printf "%3s %8s\n", "p8$aa[$i]", "AAAAAAA$aa[$i]";
}
*******************************************************************
PEDRO A. RECHE , pHD TL: 617 632
3824
Dana-Farber Cancer Institute, FX: 617 632 4569
Harvard Medical School, EM: [EMAIL PROTECTED]
44 Binney Street, D1510A, EM: [EMAIL PROTECTED]
Boston, MA 02115 URL:
http://www.reche.org
*******************************************************************