I am currently working at learning perl but come up with two problems i can't clear on my own.
I use perl version 5.8 on windows xp
The complete I am working on is supposed to find motifs in a sequence.
This is the complete code
Expand|Select|Wrap|Line Numbers
- #!/usr/bin/perl -w
- use strict;
- #Searching for motifs
- #Ask the user for the filename containing the sequence.
- print "Type the filename you want to look at: ";
- my $proteinfilename = <STDIN>;
- #remove the newline from the protein filename
- chomp $proteinfilename;
- #open the file or exit
- unless ( open(PROTEINFILE, $proteinfilename) ) {
- print "Cannot open the file \"$proteinfilename\"\n\n";
- exit;
- }
- #Read the protein sequence from the file and store it into the array variable called @protein
- my @protein = <PROTEINFILE>;
- #close the file
- close PROTEINFILE;
- #Now put everything into a single string as it is easier to search in a single string than in an array of lines (problem of line break as well.
- my $protein = join('', @protein);
- #remove whitespaces
- $protein =~ s/\s//g;
- #In a loop, ask the user for a motif, search for it and report if it was found
- #exit if no motif entered
- do {
- print "Enter a motif to search for: ";
- my $motif = <STDIN>;
- # Remove the newline at the end of $motif
- chomp $motif;
- #look for the motif
- If ( $protein =~ /$motif/ ) {
- print "I found it!\n\n";
- } else {
- print "nop. \n\n";
- }
- # exit on an empty user input,
- } until ( $motif =~ /^\s*$/ );
- #exit the program
- exit;
These are the error/warning I got:
unknown 'strict' tag(s) '1' at Findmotifs.pl line7
Syntax error line 50 near ") {"
Syntax error line 54 near "} else"
Global symbol "$motif requires explicit package name at Findmotifs.pl line 61
I first though it was because of the strict but it wasn't
What is explicit package name?
Is there anyone who can tell me where I'm wrong (particularly at line 50 and 54 as to my point of view it seems to be correct according to what I have read in my textbook)
I want to add one last thing: that I added the whole code because I know that sometimes the mistake is not exactly where perl say it is.
Thanks in advance for your help