I have a input file which I am reading into a hash table, The input file is as below

_DATA_ MANAGEMENT=IDL NORTH=IDL,NORTHERN||VIDL,NORTH||IDL,NORTH SOUTH=IDL,SOUTHERN||CIDL,SOUTH

Now for each key I have to check if another string say instance (This is also a string) contains the value. for example I check 15000 such instances against IDL which is the first value and then against (IDL AND NORTHERN )OR(VIDL OR NORTH) AND ( IDL OR NORTH )

Condition= TRUE if $instance contains (IDL AND NORTHERN) OR (VIDL AND NORTH) OR (IDL AND NORTH)

Please note that Value can many such OR conditions I have such 15000 instances against which I have to compare each value so need a fast method. I was thinking of passing the value to a function which would return a regex against which I can check but haven't been able to think of any such (I am new bee in perl)

What I am trying to achieve ?

i have a config file which has data like above (sample data, the number of OR can vary so can the number of commas. commas are nothing but 'AND' conditions) I have another array (instance) which can have number of strings ; now I want to check each one of these instances against each of the values in the hash; if the string in the array CONTAINS (not a direct match) the first value I move it to a new hash table; further check all the fields in the array against the value and do the same for all the present values from the config file

<b>Expected value of $instance</b> 1. IDL_MANAGEMENT_101001 2. IDL_NORTH_TX 3. IDL_SOUTH 4. VIDL_NORTH 5. ABX_PERL _DATA_ MANAGEMENT=IDL||VIDL NORTH=IDL,NORTHERN||VIDL,NORTH||IDL,NORTH SOUTH=IDL,SOUTHERN||CIDL,SOUTH
WorkFlow it will match IDL (the first value) against each instant and create a hash with $instance as key and MANAGEMENT as value ; in next iteration when the key is NORTH check is done $instance contains (IDL AND NORTHERN) OR (VIDL AND NORTH) OR (IDL AND NORTH) so IDL_NORTH_TX will have a new value NORTH in the resultant hash...and hence forth
Resultant Hash IDL_MANAGEMENT_101001 ==> MANAGEMENT IDL_NORTH_TX ==> NORTH IDL_SOUTH ==> SOUTH VIDL_NORTH ==> NORTH

In reply to Create a expression to cmpare a formal against a string by learnP

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.