in reply to Multi @array searches

besides the point but your
my $pattern = join "|", split " ", $terms;

is better written as my $terms =~ tr/ /|/;
as split on one thing and join with another is effectively a substition

Replies are listed 'Best First'.
(tye)Re: Multi @array searches
by tye (Sage) on Mar 22, 2001 at 22:22 UTC

    Those two solutions differ quite a bit. Something closer to the original would be:

    $terms =~ s/^\s*//; $terms =~ s/\s*$//; $terms =~ s/\s+/|/g;
    because split " " actually splits on any amount of whitespace while ignoring both leading and trailing spaces.

    Of course, if you can guarantee that the input has no lead, trailing, nor repeated spaces (and no zero-width terms), then your solution would work.

            - tye (but my friends call me "Tye")
      subtle difference but very true tye, didn't think of that one!
      at least my solution is correct 'ceteris paribus' .. probably never the best assumption to make, but hey it's getting late in the day :)