http://qs321.pair.com?node_id=11117521


in reply to Collapsing smaller scripts into a larger one, request for comment

use lib '../files/lib';
I'd use FindBin here. Regarding what all is in __DATA__, you could separate the driver code and turn each set of __DATA__ into a module. And rather than having a __DATA__ section, have an our DATA variable - since you're clearly editing this manually anyway, the work to maintain it will be the same after you convert it. This brings you closer to the suggestion, which I agree with, to separate your code from your data.

For example, index.pl becomes:

use strict; use warnings; package site::index; our $DATA = q{Welcome to Lady Aleena's B<collections>, which is lists +of A<novels|href="Fiction.pl">, A<books|href="Non-fiction.pl">, A<mus +ic|href="Music_and_comedy.pl">, A<movies|href="Movies.pl">, A<tie-ins +|href="Tie-ins.pl">, and A<programs|href="Programs.pl"> I am willing +to admit I own or use. The list of movies here is just those movies I + own and should not to be confused with my more general interest in A +<movies|href="../Movies">. Tie-ins are books and music connected to m +ovies or television series. I also share my A<fandom|href="../Fandom" +> elsewhere. Here is a key for the notations after each title with the exception of + programs.}; 1;
Fiction.pl becomes:
use strict; use warnings; package site::collection::Fiction; our $DATA = q{This is my B<fiction collection> of SPAN<hardcovers|^har +dcovers^>, SPAN<trade paperbacks|^trades^>, and SPAN<mass market pape +rbacks|^massmarkets^>.} 1;
...etc

Then you'd register these modules in your main driver, and based on whatever it is that you're dispatching on you could use the appropriate full package name to get the content via $site::index::DATA, $site::collection::Fiction::DATA, etc. I suggest this because it seems you like this style for its maintenance ease, but not for it's Perl sophistication. The solution above keeps the maintenance overhead similar to now, but is more sophisticated Perl by allowing you to eliminate the repeated calling code and implement some dispatching. And you can even keep the same .pl file names and directory structure provided you require them (which you'd have to anyway.