Excellent
thanks felix and michael.





Felix Geerinckx <[EMAIL PROTECTED]> on 04/25/2002 02:12:17 PM

To:   [EMAIL PROTECTED]
cc:

Subject:  Re: multiple greps in if()


on Thu, 25 Apr 2002 12:54:53 GMT, [EMAIL PROTECTED]
(Steven Massey) wrote:

> ideally I would like multiple grep pairs ie..
> if(grep /(Handicap && Help) || (Friend && Foe)/, $source) {
> this does not work
> }

Put the '&&' outside of the pattern:

    #! perl -w
    use strict;

    my @strings = (
        'Handicap and Help',
        'Friend and Foe',
        'Handicap and Friend',
        'Help and Foe'
    );


    for my $s (@strings) {
        if (grep { (/Handicap/ && /Help/) ||
                   (/Friend/ && /Foe/)       } $s ) {
            print "'$s' passed the test\n";
        }
    }

--
felix

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]






-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to