| | |
Perl regex
Please support our Perl advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Oct 2009
Posts: 2
Reputation:
Solved Threads: 0
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
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
•
•
Join Date: Jun 2009
Posts: 10
Reputation:
Solved Threads: 2
1
#2 Oct 28th, 2009
Perl Syntax (Toggle Plain Text)
#!/usr/bin/perl -w use strict; undef $/; # Input Record separator open (FILE, "INPUT") || die "cannot open $!\n"; my $var=<FILE>; # Assign the file handler to scalar variable close (FILE); my $match=qq{aaggtaaggt}; # Declare your text my $count=0; # ($match) -> aaggtaaggt # (.{100})? -> any 100 character match o or 1 times $count++ while ($var=~ m{($match)(.{100})?}gs); print "\nAs per rule text '$match' find $count times";
•
•
Join Date: Oct 2009
Posts: 2
Reputation:
Solved Threads: 0
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!!!!
- 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!!!!
![]() |
Similar Threads
- Perl Regex help (Perl)
- Perl Regex to VB Regex VS 2008 (VB.NET)
- Confounding Regular Expression Problem (Perl)
- add text in the c functions.plz help me (Perl)
- Extrace Pattern(E-mail ID) from text file (Perl)
- miniAudicle build errors (*nix Software)
- Trim Strings (JavaScript / DHTML / AJAX)
- C++ CGI Scripts (C++)
Other Threads in the Perl Forum
- Previous Thread: Issue with Cron and Perl Script Variables
- Next Thread: [PROBLEM] inverting a list
| Thread Tools | Search this Thread |





