OT: tied hashes

2001-09-27 Thread Steve Sapovits


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.


Steve Sapovits
Global Sports Interactive
Work Email: [EMAIL PROTECTED]
Home Email: [EMAIL PROTECTED]
Work Phone: 610-491-7087
Cell:   610-574-7706
Pager:  877-239-4003




Re: OT: tied hashes

2001-09-27 Thread lembark



-- Steve Sapovits [EMAIL PROTECTED] on 09/27/01 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

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.

sl