in reply to Mathching an array in regex
Hi,
I tried it like this,
#!/usr/bin/perl
use strict;
my @array = ('cool','guy','here');
print "Enter any word among cool/guy/here: ";
my $input = <STDIN>;
chomp $input;
my $match=0;
foreach (@array){
if ($_ =~ /$input/i){
$match=1;
}
}
if ($match == 1){
print "String matched\n";
}else{
print "No match.\n";
}