Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I'm trying to split a large chunk of code that uses shared variables and I can't get past the error "lock can only be used on shared values". Here's the reduced version of that code, in two files:
***mybase.pm:***derived.pm:package mybase; use threads; use threads::shared; my $mode : shared; 1;
***#!/usr/bin/perl package derived; use strict; use Exporter; use threads; use threads::shared; use mybase; use vars qw(@ISA); @ISA = ('mybase'); sub foo { lock($mybase::mode); $mybase::mode = 1; } foo(); 1;
[root@nf-power2 perltest]# ./derived.pm lock can only be used on shared values at ./derived.pm line 12.
Any ideas on why a variable declared as shared is not appearing as a one?
Thanks,
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: can't lock an object from a base class in a derived class
by Corion (Patriarch) on Jun 05, 2008 at 20:24 UTC |