Take a close look at the logic of your code as it stands

If you compare your version of this with the code it is based on at Re: Little pattern problem..., you'll see that you have replaced the inner while loop with an if statement. This means that instead of looping, reading new lines and pushing them onto the array until if finds a line that does match the condition, it reads one line, pushes it and then does nothing else.

Suggestion: Go back to the original code, read through it and try and understand how it works before you try to modify it. Then, when you start making changes, leave warnings and strict enabled!. If you make a change and it gives you a warning, try and understand what the warning means and correct it. Add use Diagnostics; may help you to interpret the messages. Correct any such warnings before you move on to making the next change. In the long run, you'll learn faster and achieve your goal much quicker that way.


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: 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.