Perl: inclusion / implementation of a module in a script

I have a script that uses a subclass that I wrote about a module from CPAN for presentation. Ideally, I would like to have two in one file, since there is not much code in the subclass module. It makes no sense to expand either a subclassed module to include script code, or turn a script into a module. How to include module code in a script?

+3
source share
2 answers

There are no problems with having multiple packages in one file.

package Foo;

sub new {
    print "Foo::new\n";
}

package main;

new Foo;
+10
source

, , "", core.pm, - . , script, script put require core; . use require, , .

0

Source: https://habr.com/ru/post/1789083/


All Articles