in reply to the god awful =~

you want to find out if one of a list of names is the current string named $request depending on the length of the list of names, you *might* try building a regex out of the list of names, and testing against that.

my @vnames = qw(bob carol ted alice); my $names_string = join "|", @vnames; # $names now => "bob|carol|ted|alice" # stuff if ($request =~ /$names/i) { # do stuff }

That may not be very efficient if you have a long list of names, though.

Philosophy can be made out of anything. Or less -- Jerry A. Fodor

Replies are listed 'Best First'.
Re: Re: the god awful =~
by nashdj (Friar) on Dec 04, 2000 at 11:41 UTC
    Maybe £okì wasnt 100% clear, but if you look at his script it is kind of the reverse. He wants to print out some text for each name that matches against $request.

    None the less, you have raised an interesting point, is repeating a regex better than a long disjunctive regex? In one script I have, I need to test around 300 words against a single sentence and strip them out (its just a psudo-ai type thing that needs to ignore a lot of psudo-useless words).

    The way its currently being done is simply:

    $foo =~ s/$_//i for (@list);

    Are there any faster/better ways than that?