Your code makes no sense.
The problem here is that you are trying to lock the value of a key which is a reference to a shared hash; but the reference is not (and cannot be) shared, only the hash that it refers to is shared.
Thus to lock the subhash, you need to dereference that hash reference. Eg.:
lock %{ $uber_hashRef{'%y'} };
Locks only persist for the duration of the lexical scope in which they are applied. Hence, by the time your lockit() subroutine returns, the lock will have been released; so the effect of calling it will be nothing.
In reply to Re: PERL issues a "lock can only be used on shared values" when locking a shared hash
by BrowserUk
in thread PERL issues a "lock can only be used on shared values" when locking a shared hash
by ISAI student
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |