in reply to database unclarity when finding 'unitinitaliazed' everywhere

Not that complex ;-), just do:
use strict; my %a; $a{"abc"} ++; print $a{"abc"};
Two things:
  1. In this case you don't need to initilize the hash element, as Perl will initilize it to 0 for you, in a number context.
  2. Just in case you do not know, exists is different from defined. If a hash element has value undef, than it exists, although not defined.

    This demo would help you to understand:
    use strict; my %a; check(); print "now set abc to undef\n"; $a{"abc"} = undef; check(); sub check { print "defined\n" if (defined($a{"abc"})); print "exists\n" if (exists($a{"abc"})); }

Replies are listed 'Best First'.
Re: Re: database unclarity when finding 'unitinitaliazed' everywhere
by sulfericacid (Deacon) on Mar 17, 2003 at 07:30 UTC
    Ugh, I feel like a total moron. I got errors when I originally tried doing $dbm{blah}++ rather than storing them into variables and putting it back together. I'm chosing your way as it's so much quicker to write and you don't have to fuss with making so many extra variables. My way WASN'T wrong, lol, just not as right as your's :P

    I think the error was $lost was undefined afterall, but with your method I didn't need to use variables as a dbm key.

    Thanks for your help!

    "Age is nothing more than an inaccurate number bestowed upon us at birth as just another means for others to judge and classify us"

    sulfericacid