rattytatty has asked for the wisdom of the Perl Monks concerning the following question:
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Regular expression problems
by brx (Pilgrim) on Apr 23, 2012 at 16:10 UTC | |
by rattytatty (Initiate) on Apr 24, 2012 at 08:22 UTC | |
by brx (Pilgrim) on Apr 24, 2012 at 14:16 UTC | |
|
Re: Regular expression problems
by choroba (Cardinal) on Apr 23, 2012 at 16:14 UTC | |
|
Re: Regular expression problems
by pvaldes (Chaplain) on Apr 23, 2012 at 16:21 UTC |