in reply to Re: Shared variables between threads
in thread Shared variables between threads

This is the value of $capobj just after the assignation.
pcap_tPtr=SCALAR(0x8a97fd4)

Replies are listed 'Best First'.
Re^3: Shared variables between threads
by BrowserUk (Patriarch) on Nov 05, 2007 at 09:52 UTC

    From that it seems that you are receiving a bless scalar reference. Older versions of threads shared did not allow you to assign bless references (objects) to shared variables for technical reasons.

    A recent change by jdhedden alleviated this restriction, but (unless you've already done so) you will need to download the latest versions from CPAN to be able to do this:

    print $threads::VERSION, $threads::shared::VERSION;; 1.67 1.14

    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
      I have updated my threads and threads::shared packages but no way.
      threads version -> 1.67 threads::shared version -> 1.14 Invalid value for shared scalar at RTP_media.pl line 23.
      lines 22-23
      my $capobj:shared; $capobj = Net::Pcap::open_live($dev,1024,0,0,\$err);

        You will need to threads::shared::share it before you'll be able to assign it to a shared variable.

        #! perl -slw use strict; use threads; use threads::shared; print "threads: $threads::VERSION threads::shared:$threads::shared::VE +RSION"; { my $scalar = 0xdeadbeef; my $blessed = bless \$scalar, 'main'; print 'Scalar: ', $blessed; my $shared :shared = &share( $blessed ); print 'Scalar: ', $shared; } __END__ C:\test>t-blessed.pl threads: 1.67 threads::shared:1.14 Scalar: main=SCALAR(0x1824624) Scalar: main=SCALAR(0x1824624)

        For your case that should look something like:

        my $capobj:shared; $capobj = &share( Net::Pcap::open_live($dev,1024,0,0,\$err) );

        Or just

        my $capobj:shared = &share( Net::Pcap::open_live($dev,1024,0,0,\$err) +);

        The ampasand on &share() is necessary to defeat the prototype.


        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.