in reply to using tie on two arrays on IPC::Shareable makes array1 and array2 both same even though array2 is not updated.

You instructed IPC::Shareable to connect both arrays to the same shared structure ('data').
  • Comment on Re: using tie on two arrays on IPC::Shareable makes array1 and array2 both same even though array2 is not updated.

Replies are listed 'Best First'.
Re^2: using tie on two arrays on IPC::Shareable makes array1 and array2 both same even though array2 is not updated.
by mr_p (Scribe) on Oct 06, 2009 at 18:04 UTC

    If I use antything other then 'data' like 'kala' I guess message as Could not create shared memory segment:

Re^2: using tie on two arrays on IPC::Shareable makes array1 and array2 both same even though array2 is not updated.
by mr_p (Scribe) on Oct 06, 2009 at 18:10 UTC

    This is the exact Error message that I get.

    Name "main::kids" used only once: possible typo at ./sharetest1.pl line 32. Name "main::handle2" used only once: possible typo at ./sharetest1.pl line 22. IPC::Shareable::SharedMem: shmget: No such file or directory at /nss/nfx/shmem/lib/lib/perl5/site_perl//5.8.5/IPC/Shareable.pm line 566 Could not create shared memory segment: at ./sharetest1.pl line 21

      create defaults to false. You forget to actually pass the options to IPC::Shareable.
      #!/usr/bin/perl -w use strict; use warnings; use IPC::Shareable qw( ); my @array1; my @array2; my %options = ( create => 1, exclusive => 0, mode => 0644, destroy => 1, ); my $handle1 = tie @array1, 'IPC::Shareable', 'data', \%options; my $handle2 = tie @array2, 'IPC::Shareable', 'kala', \%options;

      You also seem to forgot to connect to the share in the children. It's not documented to be inheritable.

      You might have a problem where the child destroys the share when it exits. That's why forked children should use POSIX::_exit. An alternative is to set destroy => 0 and call  IPC::Shareable->clean_up; before exiting the parent.