in reply to Is there a problem with how large the perl file gets?
In the following example, the user makes a choice and the module associated with the choice is 'require'd. The script works for $choice=1 since Data::Dumper is probably in your system. Change the choice and the script throws an error because it can't find the module.
#! /usr/bin/perl -w # use strict; use warnings; my $choice = 1; if ($choice) { if ($choice == 1) { # Do action 1 require Data::Dumper; import Data::Dumper; print Dumper(\$choice); } else { # show the user a report require Action::Report; import Action::Report; print report(); } } else { # No choice made. show help require Action::Help; print Action::Help::showHelp(); }
As a further enhancement, the module files can be pre-compiled into bytecode using B::Bytecode to help the loading time.
|
|---|