in reply to Do values from string exist within array?

Thanks for the comments so far, my array @GrpIDs now contains:
warn Dumper @GrpIDs: $VAR1='123'; $VAR2='456'; ...

String $query contains '123'. I'd like to know how to create a match/test so that I get a positive result for things which are in the array @GrpIDs that have an entry in the string $query.

Replies are listed 'Best First'.
Re^2: Do values from string exist within array?
by BillKSmith (Monsignor) on Oct 01, 2013 at 15:07 UTC
    use strict; use warnings; use List::MoreUtils qw(any); my @GrpIDs = qw(123 456); my $query = '123,567'; my $QUERY = join '|', split(/,/, $query); if (any {/$QUERY/} @GrpIDs){ print "We have a match\n"; }
    Bill