Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.

Re: Automatically add all defined functions to your @EXPORT

by ysth (Canon)
on Jun 21, 2005 at 18:58 UTC ( #468786=note: print w/replies, xml ) Need Help??

in reply to Automatically add all defined functions to your @EXPORT

To pick up declared but not defined subs, use exists &$_ instead. Also, avoid all-uppercase names.* Example:
package Foo; use strict; use warnings; our @EXPORT = do { no strict 'refs'; grep exists &$_ && /[a-z]/, keys %{ __PACKAGE__ . '::'}; }; sub bar; sub AUTOLOAD { our $AUTOLOAD; print "AUTOLOADing $AUTOLOAD\n"; } 1;
*perlsub says:
Subroutines whose names are in all upper case are reserved to the Perl core, as are modules whose names are in all lower case. A subroutine in all capitals is a loosely-held convention meaning it will be called indirectly by the run-time system itself, usually due to a triggered event. Subroutines that do special, pre-defined things include AUTOLOAD, CLONE, DESTROY plus all functions mentioned in perltie and PerlIO::via.

Update: changed [_a-z] to [a-z], based on the new CLONE_SKIP method; but perhaps that ought to be CLONESKIP...

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2023-09-22 15:04 GMT
Find Nodes?
    Voting Booth?

    No recent polls found