Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

not really sure what is a motif here, but this can't stop me to fail, of course XDD ... please, save the facepalms for the end, thanks ;-)

Only a draft, unworking and untested...but can give you some ideas

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 t +his? ## 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__

Your turn

(Updated: problem with $warn fixed)




  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others cooling their heels in the Monastery: (7)
    As of 2015-07-06 06:50 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









      Results (70 votes), past polls