Perl regex

Please support our Perl advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Oct 2009
Posts: 2
Reputation: riya0707 is an unknown quantity at this point 
Solved Threads: 0
riya0707 riya0707 is offline Offline
Newbie Poster

Perl regex

 
0
  #1
Oct 28th, 2009
I am a perl beginner and need some help with regex
Input for this code is :
aatgatgataaggtaaggtatgatgatgatgatgatagtagannnnnnnnnatgcatga'/atgca.atgactagca/atgactagcaaggtaaggtaaggtaaggtaaggtatgatgatgannnn./atgatgactagactgacaaggtaaggtaaggtatgatgatgatcgatgacgat... and so on

Here i am trying to assign input file as a scalar variable and trying to find a match of "aaggtaaggt" and then skip some 100 characters whether they are alphabets or symbols or any wildcard characters after skipping exact 100 characters, i am again asking code to start search for match again and every time it finds a match , i am counting and asking to print..

As of my knowledge i have tried using substr of match as pos1 and had set offset for 100 and then assigned that as initial pos for reading second match , but failed to get the correct output, then tried here post match as $' but doubt whether it is correct or not.

#!/usr/bin/perl
$count1 = 0;
open (FILE, "INPUT") || die "cannot open $!\n";
while ($line = <FILE>){

if(($line=~m/(aaggt){2}/ig)&&($'=~m/([atgcn]{100,})/i)) {
$count1 ++ ;
print " " ,$1, "\t";
print "count1 \t " ,$count1 , "\n" ;
}

}



Please, help me figuring out this task. Thanks
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 10
Reputation: k_manimuthu is an unknown quantity at this point 
Solved Threads: 2
k_manimuthu k_manimuthu is offline Offline
Newbie Poster
 
1
  #2
Oct 28th, 2009
  1. #!/usr/bin/perl -w
  2.  
  3. use strict;
  4.  
  5. undef $/; # Input Record separator
  6.  
  7. open (FILE, "INPUT") || die "cannot open $!\n";
  8. my $var=<FILE>; # Assign the file handler to scalar variable
  9. close (FILE);
  10.  
  11. my $match=qq{aaggtaaggt}; # Declare your text
  12. my $count=0;
  13.  
  14. # ($match) -> aaggtaaggt
  15. # (.{100})? -> any 100 character match o or 1 times
  16.  
  17. $count++ while ($var=~ m{($match)(.{100})?}gs);
  18.  
  19. print "\nAs per rule text '$match' find $count times";
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 2
Reputation: riya0707 is an unknown quantity at this point 
Solved Threads: 0
riya0707 riya0707 is offline Offline
Newbie Poster
 
0
  #3
33 Days Ago
Hi @k_manimuthu Thanks for the reply ur clear way of explaining the code was helpful and i figured it out.
Last edited by riya0707; 33 Days Ago at 9:08 pm.
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 2
Reputation: thangdd is an unknown quantity at this point 
Solved Threads: 0
thangdd thangdd is offline Offline
Newbie Poster

How to convert string to an expression in PERL

 
0
  #4
32 Days Ago
I have a quesion for my problem with using mysql and perl programming.

- data from mysql is logic expression. After query I get it's value on string format:

my $data = "$sex < 1 && $age >= 17 && $age <= 40 && ',1,2,3,' =~m/(,)$optid(,)/";

In this expression $sex,$age,$optid is variables

- How to make Perl understanding this function?
my $sex,$age,$optid;
if ($data) {
........
........
}


as

if ($sex < 1 && $age >= 17 && $age <= 40 && ',1,2,3,' =~m/(,)$optid(,)/) {
........
........
}


Please!!!!
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 40
Reputation: d5e5 is an unknown quantity at this point 
Solved Threads: 6
d5e5 d5e5 is offline Offline
Light Poster
 
0
  #5
32 Days Ago
I have a quesion for my problem with using mysql and perl programming.
I think that is a good question but to avoid confusion please start a new thread for it, instead of posting it as a reply to this thread's question.
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 2
Reputation: thangdd is an unknown quantity at this point 
Solved Threads: 0
thangdd thangdd is offline Offline
Newbie Poster

How to convert string to an expression in PERL

 
0
  #6
29 Days Ago
Originally Posted by d5e5 View Post
I think that is a good question but to avoid confusion please start a new thread for it, instead of posting it as a reply to this thread's question.
thank, I've solved my problem. By using eval function
Reply With Quote Quick reply to this message  
Reply

Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC