Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re^2: Global symbol requires explicit package name

by bebe (Novice)
on Aug 13, 2012 at 05:34 UTC ( #987029=note: print w/replies, xml ) Need Help??

in reply to Re: Global symbol requires explicit package name
in thread Global symbol requires explicit package name

but I thought I have already declared @state? I declared it as a shared variable... if I declare it again in the subs, I won't be using the same shared variable "state" anymore, right?
I'm a little bit confused... I know if I comment out "strict" it will work... but where else do you suggest I declare state?
Thank you very much
  • Comment on Re^2: Global symbol requires explicit package name

Replies are listed 'Best First'.
Re^3: Global symbol requires explicit package name
by CountZero (Bishop) on Aug 13, 2012 at 06:00 UTC
    No you did not declare @state. You declared $state which is an entirely different variable. Most probably make_shared_array() returns an array reference to you. Check the documentation.

    And BTW, dont call it as &make_shared_array(): that is very "old" style and it has side-effects you probably do not know about.

    Deleting use strict is not a good idea. It pointed an error out to you. Removing use strict does not make the error go away, only the error message, the error being that @state is not the shared variable you think it is, a very fundamental error.

    Update: A rather handy trick you can try is using Data::Dumper to inspect your arrays and hashes. Then you do not have to write all these for loops with nothing but a print inside.


    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

    My blog: Imperial Deltronics
Re^3: Global symbol requires explicit package name
by chromatic (Archbishop) on Aug 13, 2012 at 06:05 UTC

    You declared $state. If it contains an array reference, you have to dereference it.

    Improve your skills with Modern Perl: the free book.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://987029]
and the pool shimmers...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2018-04-22 03:59 GMT
Find Nodes?
    Voting Booth?