in reply to smartmatch with multiple search values
Update: I am very circumspect about smart match. Sometimes this critter is too smart! And produces unexpected results. I don't see the need for it in the above code.#!/usr/bin/perl use strict; use warnings; my $VAR1 = [ '11', '14' ]; #create a hash... my %owner_grouprights = map{$_=>1}@$VAR1; if ($owner_grouprights{'11'}) { print "test3-> 11 exists as a groupright\n"; } # you say: "the big deal -- if it only would work" WHAT?? ### what do you expect??? if (grep{/4|5|6|7|8|9|10|11|12/} keys (%owner_grouprights)) { print "test2->some number exists as a groupright\n"; #11 exists } # with loop my $testarrorig = '4|5|6|7|8|9|10|11|12'; my @testarr = split( /\|/, $testarrorig ); foreach my $tst ( @testarr ) { if (exists $owner_grouprights{$tst}) { print "$tst hit!\n"; } } __END__ test3-> 11 exists as a groupright test2->some number exists as a groupright 11 hit!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: smartmatch with multiple search values
by toohoo (Beadle) on Jul 18, 2019 at 07:15 UTC |