Below is the code to search for the FASTA file entered on the command line for the bridge provided by the user. When I launched it and entered a motive, which, as I know, is in the file, it returns "Motive not found." I'm just new to Perl, and I can't figure out how to get it to print the found motive, not to mention returning the title bar. I would appreciate any help in resolving this.
Thank.
use warnings;
use strict;
my $motif;
my $filename;
my @seq;
my $scalar;
$filename = $ARGV[0];
open (DNAFILE,$filename) || die "Cannot open file\n";
@seq = split(/[>]/, $filename);
print "Enter a motif to search for; ";
$motif = <STDIN>;
chomp $motif;
foreach $scalar(@seq) {
if ($scalar =~ m/$motif/ig) {
print "Motif found in following sequences\n";
print $scalar;
} else {
print "Motif was not found\n";
}
}
close DNAFILE;
source
share