I have not used it myself, but the ‘if’ module allows one to load modules conditionally:
use if CONDITION, MODULE => ARGUMENTS; See ‘perldoc if’ for more details. > On Dec 14, 2020, at 7:23 AM, Gary Stainburn <gary.stainb...@ringways.co.uk> > wrote: > > I've written my first re-usable modules in Perl, and all goes well. However, > I want to know if / how I can use a string variable in the 'use' clause. > > In PHP I have a simple system of turning on/off debugging and version > control. Any file *1.html is development version. I then have > > $DEBUG=(preg_match('/1.htm/',$_SERVER['REQUEST_URI'])) ? '1' : ''; > include_once("sql$DEBUG.inc"); > include_once("security$DEBUG.inc"); > > This way I have a live and a development version of every HTML and every inc > file, and putting any one file is simply a case of copying that file over. > > I'm looking to replicate this in Perl. How can I do the following? > > #!/usr/bin/perl -w > > use warnings; > use strict; > > my $DEBUG=($0=~/1$/) ? '1' : ''; > use RW::Sql$DEBUG; > use RW::Docs$DEBUG; > > I've found that you can use "require" and pass a path. I understand that > require is run time, while use is compile time. Are there any down-sides to > using require? > > -- > To unsubscribe, e-mail: beginners-unsubscr...@perl.org > For additional commands, e-mail: beginners-h...@perl.org > http://learn.perl.org/ > > Jim Gibson -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/