Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

SwaJime's scratchpad

by SwaJime (Sexton)
on Mar 15, 2013 at 20:39 UTC ( #1023773=scratchpad: print w/ replies, xml ) Need Help??

I am working with a class that contains the following code:

# Adds fields to a shared object sub set { my ($self, $tag, $value) = @_; lock($self); $self->{$tag} = shared_clone($value); }

I'm trying to add a second method similar to the first:

# Adds sub fields to a shared object sub set_alwd_info { my ($self, $tag, $value) = @_; lock($self); 43: $self->{ALWD_INFO}{$tag} = shared_clone($value); }

But I'm getting this error when I try to run it:

Invalid value for shared scalar at ./thread line 32.

Full sample code:

#!/usr/bin/perl # package ALWD::Cows; use strict; use warnings; use threads; use threads::shared qw(share is_shared shared_clone); # Constructor sub new { my $class = shift; share(my %self); # $self{ALWD_INFO} = {}; # ... ... ... my $self = bless(\%self, $class); return $self; } # Adds fields to a shared object sub set { my ($self, $tag, $value) = @_; lock($self); $self->{$tag} = shared_clone($value); } # Adds sub fields to a shared object sub set_alwd_info { my ($self, $tag, $value) = @_; lock($self); $self->{ALWD_INFO}{$tag} = shared_clone($value); } package main; my $sample = ALWD::Cows->new(); $sample->set("Key1", "Value1"); $sample->set_alwd_info("Key2", "Value2");
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2016-02-10 01:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How many photographs, souvenirs, artworks, trophies or other decorative objects are displayed in your home?





    Results (330 votes), past polls