On 08/04/2017 11:51 AM, hw wrote:
Huh? How many package statements is a module supposed to contain?
And doesn´t a package statement turn a module into a package?
package statements and files are independent!
a package statement only sets the default namespace for code that
follows it until the end of the file or ANOTHER package statement.
you can have multiple package statements in one file.
you can have multiple files with the SAME package statement. the code in
those files all live in the same namespace.
a module is just a file with (usually) a single package statement. also
a module will usually have the same name as the file. or the last part
of the package name is the file name.
the point is perl likes orthogonality. you can use package statements
how you need to use them and there are customary ways but no requirements.
when you say 'use Foo' perl will look for a Foo.pm file, load it (if
found), eval it and then call Foo->import if that method is there. in
order for that method call to work, there would need to be a 'package
Foo' statement in the Foo.pm file. that is the ONLY tie between a
package name and a module name. again, this is not a requirement but the
normal way a module is created and used.
uri
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/