in reply to Re^2: Regular Expression problem with $variable =~ m/C++/
in thread Regular Expression problem with $variable =~ m/C++/
my @matches = grep { ",$Array[$_]," =~ /,\Q$VarString\E,/i } 0..$#Arra +y;
@matches will contain the indexes (0, 1, 2 and/or 3) or the elements of @Array that contains the matching substrings. The commas ensure C won't match VISUAL BASIC, and the i ensures Perl will match PERL.
If the same item won't appear in two array elements, then you can use the following version to store the index in $match:
my ($match) = grep { ",$Array[$_]," =~ /,\Q$VarString\E,/i } 0..$#Arra +y;
|
|---|