import - import functions into callers namespace
func1()
, the scalar $foo
, and the
hash %tabs
. When someone decides to
use WhatEver
, they get those identifiers grafted
onto their own namespace. That means the user of
package whatever can use the function func1() instead
of fully qualifying it as WhatEver:: func1() .
You should be careful of such namespace pollution.
Of course, the user of the WhatEver module is free to
use a require
instead of a use
, which will
preserve the sanctity of their namespace.
In particular, you almost certainly shouldn't automatically export functions whose names are already used in the language. For this reason, the @EXPORT_OK list contains those function which may be selectively imported, as the sin() function was above. See Overriding builtin functions .
You can't import names that aren't in either the @EXPORT or the @EXPORT_OK list.
Remember that these two constructs are identical:
The import() function above is not predefined in the language. Rather, it's a method in the Exporter module. A sneaky library writer could conceivably have an import() method that behaved differently from the standard one, but that's not very friendly.