This is part of The Pile, a partial archive of some open source mailing lists and newsgroups.
To: "DBI List (E-mail)" <dbi-users@perl.org>
From: Steve Sapovits <SapovitsS@globalsportsinc.com>
Subject: OT: tied hashes
Date: Thu, 27 Sep 2001 11:49:00 -0400
This is off topic but I can't find any resources. If anyone
can point me or answer directly I'd appreciate it.
I have a hash tying package that works EXCEPT when references
are returned and used in block constructs like this:
my $h = {};
tie %$h, "MyTie";
$h->{KEY} = [];
push(@{$h->{KEY}}, (qw/foo bar/)); # THIS FAILS
The failure is: Can't use an undefined value as an ARRAY reference
If I print the value in FETCH before returning it's there.
If I assign it locally, then use it, it's also there. e.g.,
this does work:
push(@{my $x = $h->{KEY}}, (qw/foo bar/)); # THIS WORKS!
I've built about a half dozen hash ties that follow the same
model and don't exhibit this behavior. I can't include the tie
since it uses a big chuck of other code. I'm just looking for
some general approach to finding the cause.
Sorry for being off topic. Any pointers appreciated.
===
To: "DBI List (E-mail)" <dbi-users@perl.org>
From: lembark@wrkhors.com
Subject: Re: OT: tied hashes
Date: Thu, 27 Sep 2001 18:20:53 -0500
Depends on how you've written the assignment and fetch
operators. The guts of MJD's shared memory handler (IPC::Shared,
I think?) ended up having to use Storable to get around this if
you want a working example.
===
To: Steve Sapovits <SapovitsS@globalsportsinc.com>
From: Rohan Hart <rohan.hart@peace.com>
Subject: Re: OT: tied hashes
Date: Fri, 28 Sep 2001 11:25:07 +1200
Steve Sapovits writes:
> The failure is: Can't use an undefined value as an ARRAY reference
I've seen this error when playing with tied hashs - it seems to be
related to pseudo-hash behaviour, ie. Perl is mistaking your
dereference as occurring on a pseudo-hash. I couldn't find a way to
work around it
===