in reply to Subroutines loaded in from other files
Why do you want to split the subroutines into files? If you want to "encapsulate" the elements (to ensure that, for example, global variables don't "leak" between routines) you can do that within a single file by putting things in blocks:
use strict; use vars ('$really_global_var'); { # First block, the main routine my($var_in_main); main(); exit(0); sub main { SubOne::sub1(); ... } } { # Second block for the first set of things # Can also put it in its own package for further # clarity package SubOne; my($sub1_var); sub sub1 { $::really_global_var = 42; $sub1_var = 23; } }
If you require a whole load of files then it makes it harder to ship. Of course if you have a number of scripts that each use subroutines then putting everything in one file won't work.
|
|---|