Some of the suggestions already made may be better, but if you really must inline a module, some more work will be required. Also note that Exporter will not work in an inlined module.
Basically, you can write a program with an inline OO module/class by putting its package into a BEGIN block. Copying an existing module into a BEGIN block should work with appropriate code adjustments. YMMV and you will need to experiment a bit.
#!/usr/bin/perl use mymodules::foo; # Remove this line # main program here exit; # copy your modules into BEGIN blocks # be prepared to tweak & debug BEGIN{ package mymodules::foo; sub new { ... } sub bar { ... } etc ... }
In reply to Re: extract all subroutines from .pm's and include in .pl
by hangon
in thread extract all subroutines from .pm's and include in .pl
by meyerti
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |