in reply to weird problem or perl-bug?

Heard of autovivification? (btw, its documented in perlref...)
use strict; use warnings; use Data::Dumper; my @bar; my $foo = $bar[1]{bar}; die Dumper( \@bar ); __END__ $VAR1 = [ undef, {} ];

MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
** The third rule of perl club is a statement of fact: pod is sexy.

Replies are listed 'Best First'.
Re: Re: weird problem or perl-bug?
by bugsbunny (Scribe) on Dec 20, 2003 at 12:49 UTC
    yep i've heard about it... forgot about it.. have to test... thanx alot
    Does :
    print 'a' if defined $vars[xxx]{zzz};
    brings the element into existense.. i.e. how to check some element w/o turning it into existense if it doesnt exists already ?!

      print 'a' if exists $vars[xxx]{zzz};
      will check whether the hash contains an element with the key zzz, but not autovivify it.

      perl -MHTTP::Daemon -MHTTP::Response -MLWP::Simple -e ' ; # The $d = new HTTP::Daemon and fork and getprint $d->url and exit;#spider ($c = $d->accept())->get_request(); $c->send_response( new #in the HTTP::Response(200,$_,$_,qq(Just another Perl hacker\n))); ' # web
        So sorry Corion, but wrong ;)
        use Data::Dumper; my @vars; print 'a' if exists $vars[xxx]{zzz}; die Dumper \@vars; __END__ $VAR1 = [ {} ];
        First you check to see if you have a hash, then you check to see if your key exists.

        MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
        I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
        ** The third rule of perl club is a statement of fact: pod is sexy.