Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
September 24, 2012, 10:39 am
rate this thread
apply to an instance, and I can handle these OK.
However, some of the classes supply class (or global) functions.
Since none of the classes are large, I would like the whole
class set to be in a single file.
Question; what is the best way that I can:
* make sure each global function is available throughout
the source file?
* export (EXPORT!) all the global functions
when the class set is "used" ?
- Rainer Weikusat
September 24, 2012, 11:43 am
Re: exporting methods when than one package in a file?
You could add them all to the @EXPORT array. But if they're really
'class methods' I think you should be calling them like class methods,
that is, by either using an object of the proper class or the name of
it on the left side of a ->. When a subroutine is exported, what
really happens is that the coderef currently assigned to the
subroutine slot of the glob in question is assigned to the subroutine
slot of another glob. But since Perl is a dynamic language the
association between the original glob and the original coderef isn't
necessarily permanent: Any method could redefine any other method by
assigning a different coderef to the corresponding glob and such
changes will become visible to users of the class when they use
proper method calls to invoke methods but not if they import methods
as subroutines instead.
- » Can't find a syntax error, hoping a second set of eyes will help
- — Previous thread in » PERL Discussions
- » ssh on command line: force using a group size (prime size) of 1024 (and no...
- — The site's Newest Thread. Posted in » Secure Shell Forum