dime has asked for the wisdom of the Perl Monks concerning the following question:
I had the same problem with IPC::Shareable as the person in the above-mentioned post, namely orphaned memory with IPC::Shareable. I side-stepped it by using an array instead of a hash. But frankly, I don't understand why that would help. And how/why does the mentioned solution improve things?
Maybe an answer will help with my current problem as well, but in case it doesn't: I have a loop which is supposed to add to said array, but if it ends up empty, the program dies with
Can't use an undefined value as an ARRAY reference at .../Shareable.pm line 446.at the simple check
if (@array) {...}Why can't I check if the array is empty? Here's a very short version of what I have:
use IPC::Shareable (':lock'); my @arr; my %options = ( create => 'yes', mode => 0644, exclusive => 0, destroy => 'yes' ); my $handle = tie @arr, 'IPC::Shareable', 'dat1', { %options } or die " +Tie failed.\n"; #... if (@arr) { #... }
What do I need to change to make this work? Any help would be very much appreciated.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: undefined value and orphaned memory with IPC::Shareable
by perreal (Monk) on Jul 29, 2009 at 12:03 UTC |