Groovy! Many thanks.

Couple of things:

1) Any chance this will be exported into a public method someday ?

2) FYI: When I tried directly testing a ref operator (e.g., threads::shared::_id(\@ary)), it choked. I had to explicitly assign the ref to another variable, then it reports shared (which is the important bit for me).

For the record, here's a bit more complete test:

use threads; use threads::shared; package Dweeble; sub new { my $class = shift; my %obj : shared = ( cow => 'bossy' ); return bless \%obj, $class; } sub holycow { print "Holy Cow!\n"; } 1; package main; my $hope : shared = 27; my @ary : shared = (1,2,3,4,5); my $aryref = \@ary; my %hash : shared = ( one => 1, two => 2 ); my $hashref = \%hash; my $cow; my $krelboin = Dweeble->new(); print "hope is ", (threads::shared::_id($hope) ? "shared\n" : "private +\n"); print "cow is ", (threads::shared::_id($cow) ? "shared\n" : "private\n +"); print "ary is ", (threads::shared::_id($aryref) ? "shared\n" : "privat +e\n"); print "hash is ", (threads::shared::_id($hashref) ? "shared\n" : "priv +ate\n"); print "krelboin is ", (threads::shared::_id($krelboin) ? "shared\n" : +"private\n");

In reply to Re^2: Testing if variable is threads::shared ? by renodino
in thread Testing if variable is threads::shared ? by renodino

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.