I'm using Win32::MMF::Shareable 0.9 under ActiveState Perl 5.8.3, and the documented ability to select the namespace at 'tie' time does not appear to work. Is this a bug in Win32:MMF or am I somehow barking up the wrong tree?

In short, when using the following syntax:

use Win32::MMF::Shareable; my $Var2; tie $Var2, "Win32::MMF::Shareable", "Var2", { namespace => 'test' };

The namespace will be "shareable" (the default namespace), not "test". This appears to contradict the "Description" section of Win32::MMF::Shareable, which states:

Note that if you try to tie a variable without specifying the namespace, the default namespace 'shareable' will be used. If you want to change how the default namespace is created, provide the namespace, swapfile and size options when you tie the first variable.

 use Win32::MMF::Shareable;
 tie $scalar, "Win32::MMF::Shareable", "var_1",
              { namespace = 'MyNamespace', size = 1024 * 1024,
                swapfile = 'C:\private.swp' };

I have thrown together simple example programs that demonstrate this (read more below). Can anyone find anything I'm doing wrong? Alternately, does anyone know what the OO-interface equivalent of "push @tiedMMFvariable, $var;" would be, since choosing a namespace after "use" time seems to work better with OO?

Here are two "master" programs and three "client" programs:

If I run shared_master_use.pl in one window:

C:\ctl\mmf>shared_master_use.pl
Var2 is "Kenneth, what's my namespace?"
  sleeps for 5 minutes to hold Var2 in memory... 

Then I run the client programs:

C:\ctl\mmf>shared_client_use.pl
Var2 is "Kenneth, what's my namespace?"

C:\ctl\mmf>shared_client_tie.pl
Var2 is ""

C:\ctl\mmf>shared_client_use_shareable.pl
Var2 is ""

Thus we see that, when we specify namespace at 'use' time, it is set to what we specify and not the default 'shareable'. Now let's run the other master program, which specifies namespace at 'tie' time:

C:\ctl\mmf>shared_master_tie.pl
Var2 is "Kenneth, what's my namespace?"
  sleeps for 5 minutes to hold Var2 in memory... 

and I get the opposite results from my clients:

C:\ctl\mmf>shared_client_use.pl
Var2 is ""

C:\ctl\mmf>shared_client_tie.pl
Var2 is "Kenneth, what's my namespace?"

C:\ctl\mmf>shared_client_use_shareable.pl
Var2 is "Kenneth, what's my namespace?"

Here's the code to the various programs:

shared_master_use.pl
#!perl use Win32::MMF::Shareable { namespace => 'test' }; my $Var2; tie $Var2, "Win32::MMF::Shareable", "Var2"; $Var2 = "Kenneth, what's my namespace?"; print "Var2 is \"$Var2\"\n"; sleep 300;

shared_master_tie.pl
#!perl use Win32::MMF::Shareable; my $Var2; tie $Var2, "Win32::MMF::Shareable", "Var2", { namespace => 'test' }; $Var2 = "Kenneth, what's my namespace?"; print "Var2 is \"$Var2\"\n"; sleep 300;

shared_client_use.pl
#!perl use Win32::MMF::Shareable {namespace => "test"}; my $Var2; tie $Var2, "Win32::MMF::Shareable", "Var2"; print "Var2 is \"$Var2\"\n";

shared_client_tie.pl
#!perl use Win32::MMF::Shareable; my $Var2; tie $Var2, "Win32::MMF::Shareable", "Var2", {namespace => "test"}; print "Var2 is \"$Var2\"\n";

shared_client_use_shareable.pl
#!perl use Win32::MMF::Shareable {namespace => "shareable"}; my $Var2; tie $Var2, "Win32::MMF::Shareable", "Var2"; print "Var2 is \"$Var2\"\n";

In reply to Win32::MMF::Shareable tie namespaces don't seem to work? by gowen

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.