I am grabbing an email from a server and trying to match it from an array.
#!/usr/bin/perl
@array = qw/will steve frank john/;
$match = “Steve <[email protected]>"; # has to be full name and email
if (grep /$match/, @array) {
print "found it\n";
}else{
print "no match\n";
}
exit
Thanks in advance
This will match on will and steve:
Your method was looking for the full text "Steve [email protected]" in the array but it does not exist.
#!/usr/bin/perl
my @array = qw/will steve frank john/;
my $match = 'Steve <[email protected]>'; # has to be full name and email
if ( my @found = grep { $match =~ /$_/ } @array ) {
# it's there
print "Match: \n\t@found\n";
}
Output:
Match:
will steve