in reply to Best practices - if any?
"I am not writing a new module or class. Just putting couple of big subs to a safe place"If these subs are part of the same package then this is possible to achieve and then you can use the spread package by 'require'ing the filenames.pl which contain that package (File boundaries are not considered to be package boundaries in Perl). However, I wouldn't rule this out as your path to follow because I am not sure of how your code looks like..
Following is an example of the same package's subroutines being spread over a couple of files and then accessed and checked for which __package__ they belong.
#FileOne.pl package ProgramSpread; BEGIN{} sub subroutine1{ print "Hello from the sub 1 in ", __PACKAGE__, "\n"; } return 1; END{}
#FileTwo.pl package ProgramSpread; #The same package above BEGIN{} sub subroutine2{ print "Hello from the sub 2 in ",__PACKAGE__,"\n"; } return 1; END{}
UPDATE: Though this is possible, it is still not recommended for proper design.#using the package require "FileOne.pl"; #File names containing the package require "FileTwo.pl"; ProgramSpread::subroutine1(); ProgramSpread::subroutine2();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Best practices - if any?
by Anonymous Monk on Feb 21, 2010 at 13:47 UTC | |
by biohisham (Priest) on Feb 21, 2010 at 14:25 UTC | |
by Anonymous Monk on Feb 21, 2010 at 14:42 UTC | |
by Anonymous Monk on Feb 21, 2010 at 14:51 UTC | |
by JavaFan (Canon) on Feb 21, 2010 at 19:15 UTC |