Hi, I'm a novice at Perl. I am looking for help in this scenario: I want to see if a match or partial match of a $sting is found within an array. If the String = "2cat6" and the words "cat" and "catch" are both found within the array, I want to be able to get a 'true' when either word is found within the array in this case. I have tried to use m// as well as grep but if the string isn't the exact same word in the string and array it won't be found. So where $string = "2cat6" and "cat" is within the array it won't find "cat". But if $string = "catch" and "catch" is within the array it will find it but if "cat" was in the array it would not pick "cat" out of the string. All of my strings in this event are 5 letter and or number combinations in a random selection. Sometimes when the string is created some bad words are formed and I want to avoid that. Hopefully someone will help me with this.

In reply to Finding a partial match by jpys

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.