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
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<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
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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |