in reply to undefined value as an ARRAY reference: Using Tie with IPC::Shareable : New Code.

It would be a great help if you could boil this code down to something small which reproduces the error, it might also help you work out why you are getting the error.

Looking at how you are using IPC::Shareable I think this is the root of the issue - If you look at the documents, you should be tie-ing variables like so:

use strict; use IPC::Shareable; my $glue = 'data'; my %options = ( create => 'yes', exclusive => 0, mode => 0644, destroy => 'yes', ); my %colours; tie %colours, 'IPC::Shareable', $glue, { %options } or die "server: tie failed\n";

Not like you did, ($deDuppedArrayHandle is effectively the return value of the tie, not a handle on the tied variable) :

my $glue = 'data'; my %options = ( create => 1, exclusive => 0, mode => 0644, destroy => 0, ); my $deDuppedArrayHandle = tie @deDuppedArray, 'IPC::Shareable', undef, + \%options; my $filesDownloadedHandle = tie @filesDownloaded, 'IPC::Shareable', un +def, \%options;

IPC::Shareable docs tells you that

"The association between variables in distinct processes is provided by GLUE. This is an integer number or 4 character string1 that serves as a common identifier for data across process space."
While you define $glue you don't actually use it in the tie, and furthermore you then use undef as the 'glue' for both your ties.

IPC::Shareable also tells you that

"exclusive If exclusive field is set to a true value, calls to tie() will fail (returning undef) if a data binding associated with GLUE already exists. If set to a false value, calls to tie() will succeed even if a shared memory segment associated with GLUE already exists. The default is false "

The result of which is that I would imagine that either your ties are failing (and returning undef) or the tie is working, but you are then overwriting the first tie (because you didn't make the tie exclusive, or provide an alternate glue), so when you come to use it, the data isn't there. I would suspect the first though.

I might be wrong about your error (i haven't tested my theory), but IPC::Shareable can be hard to use properly, so when i do, i stick rigidly to the examples given, or experiment fully before deploying it in anything important! HTH!

Just a something something...

Replies are listed 'Best First'.
Re^2: undefined value as an ARRAY reference: Using Tie with IPC::Shareable : New Code.
by ikegami (Patriarch) on Oct 09, 2009 at 04:03 UTC
    You're wrong about him being wrong concerning tie's return value.
    my $deDuppedArrayHandle = tie @deDuppedArray, 'IPC::Shareable', undef, + \%options;
    is short for
    tie @deDuppedArray, 'IPC::Shareable', undef, \%options; my $deDuppedArrayHandle = tied @deDuppedArray;

    tie, tied