Since you have only requested assistance for two arguments, you might try something like:
if ($entry =~ /\Q$ARGV[0]\E/ && $entry =~ /\Q$ARGV[1]\E/) { # Do something }
The problem is that doesn't technically meet your requirements of ONE regexp.
This would be another way to do it with ONE regexp:
if ($entry =~ /(\Q$ARGV[0]\E.*\Q$ARGV[1]\E|\Q$ARGV[1]\E.*\Q$ARGV[0]\E) +/ { # Do something }
But that is going to be much slower and probably has about a dozen ways in which it won't work
My recommendation would be to standardize your data fields (i.e. first name, last name, etc) and then to use command line options to match them.
TelSearch.pl -f bill -l clinton
or
TelSearch.pl -l clinton -f bill
Hope this helps!
Cheers - L~R
Update: Corrected regexp that Enlil pointed out would only match one of the two arguments.
In reply to Re: regexp match arg1 AND arg2
by Limbic~Region
in thread regexp match arg1 AND arg2
by Jaap
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |