in reply to Re: Packages and modules
in thread Packages and modules

There is no "default" import behavior, so the import() example that I used earlier was as much as you needed. The only reason that it is called "import()" is because most people use it either directly or indirectly (via Exporter) for exporting symbols to the caller's namespace. If you want to define your own import() sub without losing the functionality of Exporter, look at the export_to_level() function of Exporter, which would work like this:
package Foo; use base Exporter; @EXPORT_OK=qw($foo $bar $baz); sub import { $foo = $_[0]; Foo->export_to_level(1, @_); #export symbols to caller }

No more wizardry needed than that. perldoc'ing Exporter will get you more information if you run into trouble.

Update: I apologize for not making this clear in the original post, but the above code was not intended to set $foo to the first argument passed when you say "use Foo LIST". Since "use Foo LIST" is roughly equivalent to "BEGIN { require Foo; Foo->import(LIST); }", the first argument to import() is the package name, so $foo should be set to "Foo". Yes, this was intentional. If you instead want to get the first argument, set $foo to $_[1]. If you also want to use Exporter, it is not necessarily a good idea to use shift() to remove first argument, as others have suggested, because this will make bad things happen if you subsequently call "Foo->export_to_level(1, @_);"