Hello all,
is there a way to search other than loop with smartmatch for multiple search values?
My code below
best regards
#!/usr/bin/perl use v5.10; use experimental 'smartmatch'; no warnings 'experimental::smartmatch'; $VAR1 = [ '11', '14' ]; my @owner_grouprights = @$VAR1; if ( '11' ~~ @owner_grouprights ) { print "test3\n"; } # the big deal -- if it only would work if ( {4|5|6|7|8|9|10|11|12} ~~ @owner_grouprights ) { print "test2\n"; } my $owner_grouprights = join( ' ', @owner_grouprights ); # with loop my $testarrorig = '4|5|6|7|8|9|10|11|12'; my @testarr = split( /\|/, $testarrorig ); my $testarr = join( ' ', @testarr ); foreach $tst ( @testarr ) { given( $tst ) { when ( @owner_grouprights ) { print "$_ hit!\n"; } default { #print "$_ miss\n"; } } }
In reply to smartmatch with multiple search values by toohoo
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |