Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
checking the string against all values of multidimension hashmap in perlby learnP (Initiate) |
on Nov 20, 2013 at 15:17 UTC ( [id://1063542]=perlquestion: print w/replies, xml ) | Need Help?? |
learnP has asked for the wisdom of the Perl Monks concerning the following question: I have the below requirements * Read the sample data file /tmp/user_defined_connection.ini
Each Key here can have the multiple such values ',' signifies an AND operations and '||' is an OR operation * I need to check this against another string $instance and for each value , so I take the first key MANAGEMENT and get its values and check against isntance .... `$instance` contains `IDL` or `CIDL` In next iteration same instance will be checked against the second key which is `NORTH` and if true the function should return NORTH so basically I need to check the instance against each value one by one and then return the key which i find the last... below is the code written till now How the check should work in this example checks if InterfaceAlias contains (IDL OR CIDL) , then checks if same interfaceAlias contains [(IDL AND NORTH) OR (VIDL AND NORTH) OR (IDL AND NORTHERN) , then checks if same interfaceAlias contains (IDL AND SOUTH) OR (CIDL AND SOUTH) OR (IDL AND SOUTHERN) So we have to check against all values in hash %idlcodes and return the last key with which match was TRUE The sequence is managed by the array `@providerCloudSequence` Adjacency of words is not important For example SOUTH_XXX_CIDL or even "SOUTH IDL IPV WITH SPACES" should match SOUTH_IPV....These are just examples it is basically a contains match....though the structure of file is fixed...(the data may vary)
Back to
Seekers of Perl Wisdom
|
|