Assignment:
I am given a sequence of letters, say:
XXXXXXABCDXXXXXXXX
and I am interested in part ABCD, which represents letters #7-#10 as you can see.
I am then given the same sequence, which now contains characters like * and!(only these 2 are allowed),
say:
XX**XXX!X**AB*!C*DXX*!XXX**XXX
and I want to find out which letters now represent the part ABCD.
If you count, you see that ABCD is now letters #14-#20 [4*and! were added prior to A and 10 prior to D]
What I think must be done is:
1) check how many (if any) * or/and! were added prior to start letter A(#7)
2) check how many (if any) * or/and! were added prior to end letter D(#10)
3) add all * and/or! to starting and ending letter of part ABCD
Has anyone got any hints to give me as to which functions of Perl will be useful for this problem?
If I understand the question, something like this?
#!/usr/bin/perl
$string = 'XXXXXXABCDXXXXXXXX';
$string2 = 'XX**XXX!X**AB*!C*DXX*!XXX**XXX';
foreach $str ($string,$string2) {
print "Find positions of ABCD in $str:\n";
foreach $letter ('A','B','C','D') {
## index ([string],[substring],[start])
## Index is ZERO BASED. Hence the third letter has an index of 2, so we increment it to show it's in the third position.
$index = index($str,$letter,0) + 1;
print "$letter: $index; ";
}
print "\n";
}
This should output
Find positions of ABCD in XXXXXXABCDXXXXXXXX:
A: 7; B: 8; C: 9; D:10;
Find positions of ABCD in XX**XXX!X**AB*!C*DXX*!XXX**XXX:
A: 12; B: 13; C: 16; D:18;
But of course this has nothing to do with CGI programming.
So perhaps you should have a look at O'Reillys online book shelf. Since my last try's studing biology was in 1998 - the books are most likely online for free reading.
Perl_diver, this is not a school assignment, but I wanted to make a program and gave an example of what I needed. I couldn't explain in a proggaming forum what exactly I want, and I tried to simplify it.
Rocknbil was kind enough and pointed me to some direction, my problem was greater than that.
And, I really don't see why you bother replying in a topic which seeks for help just to make fun of people who don't know as much as you do... Grow up man! We are not little children...
I have this assignment to give in Biology class and I am stuck.
not a classroom assingment? Sorry for misunderstanding your above statement then.
You have mistaken humor with making fun of people, don't be so sensitive, it's ok to laugh at yourself as well as others. Cool? (see, who even says cool anymore?) I still think you're a wonderful person and will be gald to help you with anything, except your class work ;)