Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Accessing module variables

by Eily (Monsignor)
on Apr 19, 2018 at 15:24 UTC ( [id://1213176]=note: print w/replies, xml ) Need Help??


in reply to Accessing module variables

The credentials are stored like this so that the processing scripts can be checked into github without credentials leaving the customer site.
"like this" meaning? In separate files, in .pm files, in exported package scalars? Depending on how much you can change, it might be easier to store the values in a hash in the first place:
our @Export = ( %credentials ); our %credentials = ( User => 'Joe', Password => 'Secret123' ...); # or: (User => $User, Password => $Password ...); if you want to still + define the scalars
Or even better, store them as proper configuration files with whatever format you want.

It looks like your modules are supposed to export all their variables (although you used @Export rather than @EXPORT). If that's the case, you should use require rather than use, so that you don't import each time and overwrite the $User, $Password... in your calling package.

Replies are listed 'Best First'.
Re^2: Accessing module variables
by hippo (Bishop) on Apr 19, 2018 at 15:34 UTC
    If that's the case, you should use require rather than use, so that you don't import each time and overwrite the $User, $Password... in your calling package.

    Or else leverage this to your advantage, import them each time through the loop and just refer to them by their local symbol names.

    Although I agree that it would be better not to start from here and go with config files instead.

Re^2: Accessing module variables
by talexb (Chancellor) on Apr 19, 2018 at 15:53 UTC
      It looks like your modules are supposed to export all their variables (although you used @Export rather than @EXPORT) ..

    Oh dear. What a rookie mistake. Yes, I think I meant to use EXPORT.

    In any case, clearly the credentials should be stored in configuration files and not modules .. that would make it easier for external control .. these processes are currently being handled by a crontab setup, which works well, but isn't ideal.

    Thanks for the feedback!

    Alex / talexb / Toronto

    Thanks PJ. We owe you so much. Groklaw -- RIP -- 2003 to 2013.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (2)
As of 2024-04-26 00:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found