When a module is use-ed, it can be passed a list of scalar values, strings or numbers, for the module to do with as it pleases (well, as the programmer has defined, hopefully). So in the statement
use Foo::Bar qw(func1 func2);
the Foo::Bar module is passed the list of strings 'func1' and 'func2'. In the case of
use Test::Simple tests => 1;
the module Test::Simple is passed the values 'tests' and 1 (although the latter value may be passed as a string; I'm uncertain on this point). The => (fat comma) simply insures that tests is interpreted by the compiler as a string when generating the list. (In fact, I think the statement
use Test::Simple qw(tests 1);
would work just as well, but I have not tested this.)
Update: See Perl Modules in perlmod; also see perlmodlib.
| [reply] [d/l] [select] |
The short version of what AnomalousMonk explained is that it depends on the used module how its import() deals with passed parameters.
Even shorter: Read the individual docs, and the author must tell you.
IOW: see Test::Simple
Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
| [reply] [d/l] |
As AnomalousMonk and LanX already mentioned above, the parameters after the module name (and optional version) in use are just the parameters to the import method from the package being used. That means that you can write use Foo "a", "b", "c";, use Foo qw/a b c/;, or use Foo a=>"b", "c";, and all three cases are exactly equivalent to BEGIN { require Foo; Foo->import("a", "b", "c"); }; the fat comma and qw// work in their usual way. So you see import and thereby use actually has as much flexibility with its arguments as any other Perl sub, including passing references or objects to import.
It is very common for modules to use Exporter, which provides an implementation of import that interprets the parameters as a list of functions to be exported (plus a few other things, such as tags). However, how the import method handles the parameters is totally up to the module, that's why you see it being used for things other than a list of function names sometimes.
| [reply] [d/l] [select] |