export symbols

Discussion in 'Perl Misc' started by John Kelly, Jun 23, 2010.

  1. John Kelly

    John Kelly Guest


    > use YourModule;
    > This imports all the symbols from YourModule's @EXPORT
    > into the namespace of the use statement.


    > use YourModule ();
    > This causes perl to load your module but does not import any symbols.


    Specifying () every time seems safe, but a hassle. Without reading the
    source, can I get a list of default export symbols for a module?




    --
    Web mail, POP3, and SMTP
    http://www.beewyz.com/freeaccounts.php
     
    John Kelly, Jun 23, 2010
    #1
    1. Advertising

  2. John Kelly <> writes:

    >> use YourModule ();
    >> This causes perl to load your module but does not import any symbols.

    >
    > Specifying () every time seems safe, but a hassle. Without reading the
    > source, can I get a list of default export symbols for a module?


    Some modules (ab)uses the import() methods for other things than
    polluting your symbol table. These modules might work differently.

    This is partly documented in 'perldoc -f use':

    If you do not want to call the package's "import" method (for
    instance, to stop your namespace from being altered),
    explicitly supply the empty list:

    use Module ();

    That is exactly equivalent to

    BEGIN { require Module }

    If the VERSION argument is present between Module and LIST,
    then the "use" will call the VERSION method in class Module
    with the given version as an argument. The default VERSION
    method, inherited from the UNIVERSAL class, croaks if the given
    version is larger than the value of the variable $Module::VERSION.

    Again, there is a distinction between omitting LIST ("import"
    called with no arguments) and an explicit empty LIST "()"
    ("import" not called). Note that there is no comma after
    VERSION!

    //Makholm
     
    Peter Makholm, Jun 23, 2010
    #2
    1. Advertising

  3. John Kelly

    John Kelly Guest

    On Wed, 23 Jun 2010 07:57:53 -0500, Tad McClellan <>
    wrote:

    >>> use YourModule ();
    >>> This causes perl to load your module but does not import any symbols.


    >> Specifying () every time seems safe, but a hassle.


    >In _my_ cost/benefit analysis, typing 2 characters in return
    >for safety wins...


    I meant it's a hassle to package qualify every symbol I want to use. I
    like writing terse code with short names. So if a package doesn't step
    on my names, I may want its symbols in main.

    It would be nice if there was a warning when package symbols step on
    symbols already in main.


    > perl -MCarp -le 'print for @Carp::EXPORT'


    I'll try that. Thanks for the tip.



    --
    Web mail, POP3, and SMTP
    http://www.beewyz.com/freeaccounts.php
     
    John Kelly, Jun 23, 2010
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?RGF2aWQgVmFsbGU=?=

    Invalid export DLL or export format

    =?Utf-8?B?RGF2aWQgVmFsbGU=?=, Oct 29, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    3,640
    =?Utf-8?B?RGF2aWQgVmFsbGU=?=
    Oct 29, 2003
  2. =?Utf-8?B?QUs=?=

    Debug symbols not for all .aspx forms.

    =?Utf-8?B?QUs=?=, Jan 19, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    910
    Habib Heydarian [MSFT]
    Jan 23, 2004
  3. ernesto

    Cannot export class symbols

    ernesto, Jun 28, 2005, in forum: C++
    Replies:
    1
    Views:
    495
    Victor Bazarov
    Jun 28, 2005
  4. ernesto

    Export symbols from .a files

    ernesto, Jul 5, 2005, in forum: C++
    Replies:
    1
    Views:
    346
    Victor Bazarov
    Jul 5, 2005
  5. Maarten Porters
    Replies:
    1
    Views:
    436
    Florian Gilcher
    Jul 28, 2008
Loading...

Share This Page