Front page | perl.beginners |
Postings from January 2002
Re: USE IMPORT REQUIRE
Thread Previous
From:
Jeff 'japhy' Pinyan
Date:
January 5, 2002 07:19
Subject:
Re: USE IMPORT REQUIRE
Message ID:
Pine.GSO.4.21.0201051015080.1378-100000@crusoe.crusoe.net
On Jan 5, nafiseh saberi said:
>what is the difference between
>"use" , "import" , "require".
The code:
use Module qw( this $that );
is the same as:
# BEGIN { } happens at compile-time
BEGIN {
require Module;
Module->import(qw( this $that ));
}
Read 'perldoc -q require' for more about how 'use' and 'require' differ.
As for what 'import' is, it's not a builtin function or operator. It's a
method Perl expects your package to have, and it defines how to import
symbols (such as functions and variables) from the package being used to
the package doing the importing.
You should probably read 'perldoc Exporter' to see how the general
importing mechanism works.
--
Jeff "japhy" Pinyan japhy@pobox.com http://www.pobox.com/~japhy/
RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **
<stu> what does y/// stand for? <tenderpuss> why, yansliterate of course.
Thread Previous