go ahead... be a heretic | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
As I understand it 'use' actually does two things, both of them conditionally:
1. Perform a sort of compile-time 'require' *only if* this module hasn't been 'use'-d before. A table of what modules have already been loaded is maintained in some variable that I don't recall at the moment. 2. Call the 'import'-function (I think) *if* it is present in the 'use'-d package. This is performed on every occurence of 'use'. The import function is the one that can optionally export symbol-names (like your constants) to the calling package. Building your own import function is a hassle, so the easy way is to use the standard Exporter package... The man-page of the Exporter package can explain everything you want to know (and a lot more) about exactly how to use it. For starters, this should do: --file foo.pm-- If you'd just require'd the foo package, you would need to use $foo::const1 to access the constant. If you'd use'd the foo package, the same would still work, but you would also have access using $const1 from the calling package. Hope it helps... In reply to Re: Re: require() turns off strict?
by Gilimanjaro
|
|