One quick and dirty way to do this is to declare some
variables in the script, eval require the file, if eval
succeeds equate the script var names with the var names
in the required file.
use strict;
use vars qw($filevar1 $filevar2 $filevar3);
my($scriptvar1,$scriptvar2,$scriptvar3,$required) = 0;
my$file = 'somefile';
if(-e $file){
if(eval "require '$file'"){
$scriptvar1 = $filevar1;
$scriptvar2 = $filevar2;
$scriptvar3 = $filevar3;
$required = 1;
}
}
Those
my variables can be included in the use
vars
statement instead (but not vice-versa).