in reply to Re: Re: Autovivification not working?
in thread Autovivification not working?
2;0 juerd@ouranos:~$ cat test.pl #!/usr/bin/perl -w use GDBM_File; use strict; unlink 'karmatest'; my $hashref = { hash => {} }; $hashref->{object} = tie %{ $hashref->{hash} }, 'GDBM_File', 'karmates +t', GDBM_WRCREAT, 0640; sub resolve { return \ $hashref->{hash}{$_[0]}; } # Warning! ${ resolve('this one does not exist') } += 2; # now, the same, but without tie: my $second = { hash => {} }; sub resolve_again { return \ $second->{hash}{$_[0]}; } # No warning! ${ resolve('this one does not exist') } += 2; 2;0 juerd@ouranos:~$ perl test.pl Use of uninitialized value in addition (+) at test.pl line 13.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Re: Autovivification not working?
by jepri (Parson) on Dec 20, 2001 at 19:55 UTC | |
by Juerd (Abbot) on Dec 20, 2001 at 20:04 UTC |