in reply to Re: Re: Best way check key availability
in thread Best way check key availability

Nope. It won't. Observe:
use strict; my %a; if ($a{'foo'}) {} print keys %a;

According to your claim, this should print "foo". Well, it doesn't ;-)

Liz

Replies are listed 'Best First'.
Re: Re: Re: Re: Best way check key availability
by hardburn (Abbot) on Sep 11, 2003 at 21:00 UTC

    I think our Anony Monk was thinking about multi-dimentinal hashes:

    my %a = ( foo => { }, bar => { }, ); if($a{baz}{key}) { }

    In this case, 'baz' is created in the first dimention. Since we're dealing with a single-dimentional hash, our Anony Monk was incorrect.

    ----
    I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
    -- Schemer

    Note: All code is untested, unless otherwise stated