Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^5: global var

by poj (Abbot)
on Apr 06, 2017 at 15:19 UTC ( [id://1187306]=note: print w/replies, xml ) Need Help??


in reply to Re^4: global var
in thread global var

imports everything into that module, even subs/scalars

The advice in What_Not_to_Export regarding scalars is this

Do not export variable names. Just because Exporter lets you do that, it does not mean you should.
 @EXPORT_OK = qw($svar @avar %hvar); # DON'T!
Exporting variables is not a good idea. They can change under the hood, provoking horrible effects at-a-distance that are too hard to track and to fix. Trust me: they are not worth it. To provide the capability to set/get class-wide settings, it is best instead to provide accessors as subroutines or class methods instead.

Which is where I think this node started with the problem

$userid = $manageusers::LoggedOn_user_id;

and I think you were on the right path here in eliminating the global variables

I also changed $LoggedOn_user_id to a function call &GetLoggedOn_user_id to deliver the number to the other module and it still does not work.

I think you now know to make it work.

poj

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1187306]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (2)
As of 2024-04-20 04:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found