in reply to Trying to be stricter...
If all I want to import are a batch of config variables, I've require'd a file consisting of subs that return some value or another, like:
If I want to import some simple set of subroutines (housekeeping stuff mostly... subs that don't really belong anywhere else) I'll make a file of subs and require them like before, except I'll (obviously) pass values into and out of the sub instead of just "out" as above. If you have a truly global variable that you want your imported subs to see, use "use vars " or "our" to declare your global variable.# Contents of config.pl sub big_list { return qw(some enormous list of variables); } # And then in my program... require config.pl; my @big_list = big_list();
Of course, if I have a batch of config variables or subs that actually belong together the best place is to put it into a full-blown module. I won't build a module unless it makes sense, though. I have literally used all three techniques in different parts of the same project. Whichever fits you best. All three techniques are ways to re-use code, and re-using code is right up there with cleanliness and godliness. So, at least in my opinion, it's aaallllll gooooooddddd.
Gary Blackburn
Trained Killer
|
|---|