in reply to Re: Faster of two options for finding keywords in a database
in thread Faster of two options for finding keywords in a database

"FWIW your use of defined is also error prone, exists it's the way to go." More about this, please?
  • Comment on Re^2: Faster of two options for finding keywords in a database

Replies are listed 'Best First'.
Re^3: Faster of two options for finding keywords in a database
by LanX (Saint) on Feb 20, 2024 at 00:05 UTC
    As soon as undef is used as value, your code will break. Better be safe than sorry.

    Debugger demo:

    DB<2> $h{a}=1 DB<3> $h{b}=undef DB<4> x grep {defined $h{$_}} "a".."d" 0 'a' DB<5> x grep {exists $h{$_}} "a".."d" 0 'a' 1 'b' DB<6>

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    see Wikisyntax for the Monastery