API for import?

Discussion in 'Perl Misc' started by kj, Feb 13, 2004.

  1. kj

    kj Guest

    Where can one find good documetation on the API for the import
    function and whatever other information one must know to write
    one's own import function? (Neither 'perldoc -f import' and pointers
    therein, nor reading the Export.pm source code were particularly
    illuminating on this question.)

    Thanks!

    kj
    kj, Feb 13, 2004
    #1
    1. Advertising

  2. kj

    Ben Morrow Guest

    kj <> wrote:
    >
    > Where can one find good documetation on the API for the import
    > function and whatever other information one must know to write
    > one's own import function? (Neither 'perldoc -f import' and pointers
    > therein, nor reading the Export.pm source code were particularly

    ^^ er
    > illuminating on this question.)


    perldoc -f use
    perldoc perlmod

    Think carefully before you start though: is it *really* necessary to
    write your own? Exporter covers most cases...

    Ben

    --
    don't get my sympathy hanging out the 15th floor. you've changed the locks 3
    times, he still comes reeling though the door, and soon he'll get to you, teach
    you how to get to purest hell. you do it to yourself and that's what really
    hurts is you do it to yourself just you, you and noone else *
    Ben Morrow, Feb 13, 2004
    #2
    1. Advertising

  3. kj <> writes:

    > Where can one find good documetation on the API for the import
    > function


    When you write your own import() you get to define your own API!

    In older versions of Perl you needed to do version checking but
    this is now handled by a separate VERSION method.

    Old modules' import() still may need keep the legacy version checking
    code to support the legacy syntax:

    use Module VERSION, LIST

    New modules don't need to worry about this as new code will use one of:

    use Module VERSION LIST
    use Module VERSION

    This means you have a completely free hand in your import's API.

    > and whatever other information one must know to write
    > one's own import function?


    You need to know what you want it to do. You have to supply that
    information yourself.

    > (Neither 'perldoc -f import' and pointers
    > therein, nor reading the Export.pm source code were particularly
    > illuminating on this question.)


    I'm not quite sure what "this question" is. I suspect it doesn't
    really exist, you only imagine it does. Getting answers to questions
    whose existanve you are imagining is often very difficult.

    That said you may also want to consult:

    perldoc -f use
    perldoc perlmod

    The only bit I found unclear was how Perl manages to DWIM for both:

    use Module VERSION
    use Module LIST [where LIST contains a single element]

    From experimentation it seems that if the abiguous argument is a
    number literal or a version literal it is seen as VERSION otherwise
    it's seen as LIST. Which seems right from a DWIM standpoint.

    If you want to force something that would usually
    be treated as a VERSION to be treated as sigle element LIST the
    parentheses or a unary plus seem to do the trick.

    --
    \\ ( )
    . _\\__[oo
    .__/ \\ /\@
    . l___\\
    # ll l\\
    ###LL LL\\
    Brian McCauley, Feb 13, 2004
    #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. Paul Opal
    Replies:
    12
    Views:
    926
    Paul Opal
    Oct 11, 2004
  2. JPractitioner
    Replies:
    13
    Views:
    20,118
    Roedy Green
    Feb 24, 2006
  3. Vitali Gontsharuk
    Replies:
    2
    Views:
    555
    Vitali Gontsharuk
    Aug 25, 2005
  4. Artur M. Piwko

    import/from import question

    Artur M. Piwko, Jun 29, 2003, in forum: Python
    Replies:
    1
    Views:
    824
    Peter Hansen
    Jul 2, 2003
  5. Dennis
    Replies:
    2
    Views:
    488
    Dennis
    Aug 18, 2003
Loading...

Share This Page