Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Automatically add all defined functions to your @EXPORT

by tlm (Prior)
on Jun 21, 2005 at 15:26 UTC ( [id://468716]=note: print w/replies, xml ) Need Help??


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

Not only very handy, but IMO, a textbook example of the Snippet genre.

I will make a tiny modification for my use:

grep +( defined &$_ and !/^_/ ), keys %{ __PACKAGE__ . '::'};
...to keep _private_functions and __ANON__...s unexported.

Update: I just realized that what I wrote above is almost identical to merlyn's earlier earlier follow-up... D'oh!

the lowliest monk

Replies are listed 'Best First'.
Re^2: Automatically add all defined functions to your @EXPORT
by merlyn (Sage) on Jun 21, 2005 at 15:53 UTC
    __ANON__
    I realize you struck that out, but I just tested, and even though creating an anonymous subroutine pokes an __ANON__ into the symbol table, the defined test fails, so this would never pick up on that. Unless you happened to also call a subroutine __ANON__.

    -- Randal L. Schwartz, Perl hacker
    Be sure to read my standard disclaimer if this is a reply.

      Well, I'm glad you checked, because I had a (rather embarrassing) bug in my test, which incorrectly showed the __ANON__s as passing the defined &$_ .

      the lowliest monk

Log In?
Username:
Password:

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

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

    No recent polls found