in reply to no grep match returns undefined?

grep returns an array of matched elements. So if there are no matches, then the first array element is undefined. A better way would be
my @vndr_keys = grep { $args->{desc} =~ m/$_/i } keys %vendors; if (@vndr_keys) { #do something } else { #do something else }
-Mark

Replies are listed 'Best First'.
Re: Re: no grep match returns undefined?
by davorg (Chancellor) on Sep 05, 2002 at 16:22 UTC
    grep returns an array of matched elements

    Actually it returns a list of matched elements.

    The difference can be important.

    --
    <http://www.dave.org.uk>

    "The first rule of Perl club is you do not talk about Perl club."
    -- Chip Salzenberg