perl package inside a package -
I need to create a normal package that will be used by other packages, such as:
common_1 pm is in:
Package Normal; Use Test1; Use test2; and use this package in another package, as follows:
contents of test_case1.pm:
package test_case1 ; Use mangoes; // it should use test1 and use test1 and test2; Use test4; Each trial * .pm is again a separate Perl module, can I write packages like the above? I'm new to the opul in Pearl, thanks in advance for help.
Yes, this can be done; Examples of such things are, and
I want to use this as a tool for building such a module.
These are examples of how this can be done: syntax :: collector:
package general; Use syntax: collector-collection = & gt; Use Q {test1; Use test2 0; }; 1; or by importing: in:
Package Normal; Import :: In use; Use test1; Use Test2; Sub import {my $ caller = shift; test1- & gt; Import :: ($ Caller); test2- & gt; Import :: ($ Caller); } 1; If test1 and test2 are actually object-oriented modules (i.e. they are classes or roles), then there is no need for it, it has been said, To import them at all, the following will be sufficient:
Package Normal; Use test1; Use Test2; 1;
Comments
Post a Comment