Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Create a expression to cmpare a formal against a string

by hdb (Monsignor)
on Nov 12, 2013 at 09:44 UTC ( #1062162=note: print w/replies, xml ) Need Help??


in reply to Create a expression to cmpare a formal against a string

Your example output is not quite correct and I think your problem is still not fully specified. However, have a look at this and see whether you can adapt it for your purposes.

use strict; use warnings; sub check_condition { my( $inst, $cond, $ors ) = @_; OR: for ( @$ors ) { $inst !~ /$_/ and next OR for @$_; return 1; } return 0; } sub check { my( $inst, $list ) = @_; return grep { check_condition $inst, $_, $list->{$_} } keys %$ +list; } my %conditions = map { /^(.*?)=(.*)$/; $1 => [ map { [ split /,/ ] } split /\|\|/, $2 + ]; } <DATA>; my @instances = qw( IDL_MANAGEMENT_101001 IDL_NORTH_TX IDL_SOUTH VIDL_ +NORTH ABX_PERL ); print "$_:", join(",",check( $_, \%conditions )), "\n" for @instances; __DATA__ MANAGEMENT=IDL NORTH=IDL,NORTHERN||VIDL,NORTH||IDL,NORTH SOUTH=IDL,SOUTHERN||CIDL,SOUTH

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1062162]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2022-01-22 18:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (63 votes). Check out past polls.

    Notices?