Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: hash pm

by fullermd (Curate)
on Nov 30, 2010 at 03:04 UTC ( #874419=note: print w/ replies, xml ) Need Help??


in reply to hash pm

You'll need to make it a package variable (our and probably exported, or explicitly call it as Package::varname) instead of a lexical (my).

$MYconf::vars = { <stuff> };


Comment on Re: hash pm
Select or Download Code
Re^2: hash pm
by toniax (Scribe) on Nov 30, 2010 at 03:22 UTC
    Thanks for the info.
    After reading about Perl modules I now realize it is more involved .
    I will just have to read more about it

      The important bit to remember in this case is that "modules" and "packages (namespaces)" and "files" often exist in 1:1:1 ratios, but don't necessarily have to. That's just the common and convenient way.

      What you want is for this variable to be visible from outside this {file,module}. Using my is wrong for that, since my creates a lexical variable, which is limited to the current scope (and the largest scope it can occupy is a file, so it can't be gotten at from outside).

      So it has to be a package variable of one sort or another. It can live in the package of this module, and be exported (via Exporter, or manual trickery if you're insane). It can live in that package and not be exported, and thus accessed only by its fill name $My::Package::vars. Or you can just invent a package namespace for it, and call it $MyConfig::vars everywhere. You may have to read up on how packages work in perl if that doesn't make sense...

      The most obvious (and probably right) Way To Do It in this case is just to make it a package variable in that module's package, declare it in that file with our instead of my, and either use Exporter or refer to it by full name in other files. The various other solutions mentioned above are comparatively less likely to be the best choice.

        Thanks for all the info I found some good links that explain pm files tutorialspoint.com and
        wikipedia.org I would use perldoc but they are like the Unix man pages,
        good if you forget something and need to look it up , not really too good for learning (well for me anyway)

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (16)
As of 2014-08-21 14:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (136 votes), past polls