The rebuke wasn't intended to come across as harsh. Sorry that it did.

Moving right along. Could you explain a little more of what you mean by ...but I couldn't get your program to work as stated...? I just downloaded the code again and it produced the output I listed, which show that two keys were created. The first with three probes found

1415671 : GGAACAGGAATGTCGCAACATCGTA, ACATCGTATGGATTGCTGAGTGCAT, GGCTGATCACATCCAAAAAGTCATG

And the second with 10:

1415670 : GAGGAAACGTTCACCCTGTCTACTA, GTTCACCCTGTCTACTATCAAGACA, TACTATCAAGACACTCGAAGAGGCT, CTGTGGGCAATATTGTGAAGTTCCT, GAATGCATCCTTGTGAGAGGTCAGA, GAGAGGTCAGACAAAGTGCCAGAAA, AAAACAAGAACACCCACACGCTGCT, ACACGCTGCTGCTAGCTGGAGTATT, TATCTTGTCCAACACTACGTCGAAG, TTGTCACCATGCCTGCAAGGAGAGA

This is as expected from the sample data you provided on that original post, although I've manually wrapped it to prevent it getting confused by the autowrapper.

If you are getting different output when you run my original code, then could you post the output you get please and I'll try to work out what could be different.

The way $target name gets updated in the original is like this.

do { # extract the target name $target_name = $1 if m[( \d{7} ) _at: \d{3} : \d{3} ]x; while( m[$target_name] ) { # process the record containing the current target name my $probe = <DATA>; # Read the probe chomp $probe; # save it in an HoA keyed by the target name push @{ $probes{ $target_name } }, $probe; # get the next line; last unless defined( $_ = <DATA> ); } } until eof DATA; # till done

$target_name is set at the top of the outer do..until loop.

The code enters the inner while loop, reads the next line, extracts the probe pushes it onto the HoA.

It then gets to the last unless defined... line, where it reads another line. So long as it hasn't reached the eof, then it loops back to the top and tests the while condition again. If it matches, the loop repeats, another probe is read and pushed.

If it doesn't, then it falls out of the while loop and the until eof DATA condition is tested. If it's not at the eof, then it loops back to the top of the do...until loop and the new $target_name is extracted from the last line it read (which failed to match the while condition) and the cycle repeats.

Hopefully, that explains how it works and will allow you to modify it to your needs.


Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller
If I understand your problem, I can solve it! Of course, the same can be said for you.


In reply to Re: Re: Re: Why is it matching?? by BrowserUk
in thread Why is it matching?? by bioinformatics

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • 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, details, 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, summary, 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.