use 5.010; my ($file, $motif) = @ARGV; my $warn = <<'EOF'; Number or arguments incorrect, Please run this program with 2 arguments, a file and a motif to count the number of letters between any two motifs: i.e. perl script.pl myfile mymotif EOF if (scalar @ARGV != 2) {print $warn} if (scalar @ARGV == 2){ open (my $DNAFILE, '<', $file) or die "I need that you provide a file. Cannot open file $!"; ## $DNAFILE = join( '', @DNA); ## don't understand this line ... can you explain this? $DNAFILE =~ s/\s//g; # Remove whitespace, ok if ( $DNAFILE =~ /$motif/ ) { print "\nI found it!\n"; # Count number of nt between two motifs my $string ="@DNA"; # same question, explain please, why do you need this? ## mmmh... are you trying to say "\@DNA"? say "Lengths are:", $_ for map { sprintf("%d", length) } split /$motif/, $string; # Count number of motifs my $count=($string =~ m/$motif/g); print "Number of motifs: $count.\n\n"; close DNAFILE; } else { print "The motif: $motif was not found in the file $file.\n"} } # first else block __END__