in reply to regexp match arg1 AND arg2

There is definately MTOWTDT.

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.

Replies are listed 'Best First'.
Re: Re: regexp match arg1 AND arg2
by Jaap (Curate) on Feb 17, 2003 at 16:29 UTC
    No i am sorry but people can use any number of arguments that must match. So your solution will not work :(
      Then I suggest you try one of the suggestions that broquaint already pointed out, or you take my advice and structure the data and provide command line options.

      Cheers - Limbic~Region