I have a problem with a pattern match. I want to print what the match is whether it be by using $1 or assigning the match to another variable. It seems to be taking a scalar of the value instead of the value and I don't know why unless perl 5.10.1 is an issue
my $procount2 = 1; foreach my $readingframe2(@protein){ my $protein; print "string is $readingframe2\n"; my $fada; if($readingframe2 =~ /MHGR/){ print "$1\n"; ($protein)= $readingframe2 =~ /MHGR/; $fada = length($protein); print "motif is $protein\n"; if($fada >=1){ print "length of motif is $fada\n"; print OUT1 "Protein $procount2\n$protein\n"; $procount2++; } } }
Here is what comes up in the console:
$ perl readingframe.pl Enter file name t.txt Enter output file name o.txt string is MHGRRRRRRRRRRRRRRRRRRRRRRRRRRRRRD_MHGRRRRRRRRRRRRRRRRRRRRRRR +RRRRRRD_ Use of uninitialized value $1 in concatenation (.) or string at readin +gframe.pl line 68, <> line 2. motif is 1 length of motif is 1 string is CMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVTECMAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAVT string is AWPPPPPPPPPPPPPPPPPPPPPPPPPPPPP_LNAWPPPPPPPPPPPPPPPPPPPPPPPP +PPPPP_L
In reply to Regular expression problems by rattytatty
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |