I'm looking at the source of base.pm
in the Perl distribution, and I don't see what distinguishes it from a "non-pragmatic" module. If use base
is a "pragma", is it fundamentally different in any way from use Foo
where Foo
is any module?
A Perl package is a collection of code which resides in its own namespace. Perl module is a package defined in a file having the same name as that of the package and having extension . pm. Two different modules may contain a variable or a function of the same name.
In Perl, the use keyword is exactly equivalent to the following: use Mymodule; #is the same as BEGIN { require Mymodule; Mymodule->import(); } So if you are not defining an import routine in your code (or inheriting from Exporter ), then your modules are not importing anything into test.pl.
There's no solid definition for pragma. The closest to something official is in perlpragma.
I personally believe those are requirements (and it seems that perlpragma does too), but core modules vars and subs are documented to be pragmas even though their effect isn't lexically scoped.
base and lib don't match either of the criteria. What they do is provide information to "Perl itself". I guess that also qualifies as a pragma.
I consider my module use syntax qw( loop );
to be pragmatic. (Shameless plug!)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With