Thank you for your responses. I just realized that I actually offered an incorrect example. Let me share some actual code so you can see what I am working with and it will make more sense.

I read in lines from a file. The file contains one URL per line each starting with "/". For instance, "/help.html" or "/index.html" or "/help.html?ri=all". Each line gets stored into an array @line_entry.

Once all lines have been parsed into @line_entry, I iterate through $line_entry[$i]. At each iteration I do the following:

given ($line_entry[$i]) { when ($_ ~~ @INDEX_PAGE) { $INDEX_PAGE_COUNT++; } when ($_ =~ m/@HELP_PAGE/) { $HELP_PAGE_COUNT++; } }

In the case of @INDEX_PAGE, the reason I can get away with using that type of when condition is because the only possibly URLs that cane be parsed from the file are the only two that appear in the array @INDEX_PAGE = {"/", "/index.html"}. There is no regex required since there is no "/index.html?something". It is guaranteed to either be "/" or "/index.html".

However, array @HELP_PAGE = {"/help.html"} is defined as such, but the entries that can be found in the URL file may be "/help.html", but they could also be "/help.html?sometexthere". So I am trying to find the proper means to see if an element in an array is a subset of the string I'm currently examining, and not the other way around as I suggest in my initial post.

Thus, if the string currently being analyzed is ANYTHING that begins with "/help.html" (the element in the @HELP_PAGE array), it should resolve true.

Thank you again for your continued assistance!


In reply to Re: Searching for a string within an array using regex by Aquilae
in thread Searching for a string within an array using regex by Aquilae

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.