Thanks! This works flawlessly.

I just had one more question. How do I avoid printing out values that are not found? So currently it prints out all 5 even if one of the match is not found.
AB : 135172
FG : 248782
AD : 64
AE : 0
AC : 0

I would like to avoid AE and AC in this case since they are not found.

Also, two more requirements just came up. There is a one word description attached to each string I am supposed to find and they are supposed to be printed alphabetically.

Would I need to make a separate array to print out description next to each string I am printing? This is what the result should look like:
AB(ABYUSID) : 135172
FG(FGIUIO) : 248782
AD(ADHGUT) : 64
AE(AERUTOT) : 0
AC(ACVHGTI) : 0
Would I need to store these one word descriptions in a separate array and print from there? I tried doing it that way but then it becomes infinite loop and keeps printing these values every time they are found
Thanks for all the help!

In reply to Re^3: Reading through a file and checking for a specific string by vihar
in thread Reading through a file and checking for a specific string by vihar

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.