|
||||||
| Perl Discussion for the PERL language - Practical Extraction and Reporting Language, is a programming language often used for creating CGI programs. |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
Really mate, this is too simple, next time post some code you have tried.
two ways: Code:
$input = 'AAXXXAAXXXAAXXAXA'; $count = $input =~ s/(AA)/$1/g; print $count; $input = 'AAXXXAAXXXAAXXAXXA'; $count = () = $input =~ /AA/g; print $count; AAXXXAAXXXAAXXAXAAAXXAAAAAXXAA |
|
|||
|
as for that, i still have to verify with my teacher in school. to see what he gonna say about that.
btw thanks for helping. input : AAXXXXAAXXXACXXXACXXX i would like to count the times AA and AC occurred separately. i try using your method. but the output is not what i want. and i try using "if" statement. it's still the same output which is not what i expected. this is the code for "if" statement. if($seq =~ AA) { $countAA = $seq =~ s/(AA)/$1/g; print "\nNumbers of AA pairs occurred: $countAA"; } if($seq =~ AC) { $countAC = $seq =~ s/(AC)/$1/g; print "\nNumbers of AC pairs occurred: $countAC"; } |
|
|||
|
the "if" conditions are not necessary:
Code:
$seq = 'AAXXXXAAXXXACXXXACXXX'; $countAA = $seq =~ s/(AA)/$1/g; print "\nNumbers of AA pairs occurred: $countAA"; $countAC = $seq =~ s/(AC)/$1/g; print "\nNumbers of AC pairs occurred: $countAC"; both substrings (AA and AC) are counted twice, so the code works as expected. From now on if you post questions I will not reply unless i see the code you have been writing and trying. That is my personal policy for helping students. |
| Sponsored Links |
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
| neerlin | ........ | |
| satrian | ........ | |
| jackluxford | ........ | |
| =At | ........ | |
| Xav | ........ | |
| MeTh0Dz|Reb0rn | ........ | |
| gamiR | ........ | |
| chili5 | ........ | |
| liljp617 | ........ | |
| Fred@eisfi | ........ |
Goal: 100,000 Posts
Complete: 67%