Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

API for import?

3 views
Skip to first unread message

kj

unread,
Feb 13, 2004, 10:54:19 AM2/13/04
to


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

Ben Morrow

unread,
Feb 13, 2004, 1:44:16 PM2/13/04
to

kj <nom...@please.com> 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 * b...@morrow.me.uk

Brian McCauley

unread,
Feb 13, 2004, 2:27:51 PM2/13/04
to
kj <nom...@please.com> 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\\

0 new messages