in reply to Re: Using variables within packages
in thread Using variables within packages

OK

Firstly, I have used the AUTOLOAD code form Perl Black Book

package Autoload; BEGIN { use Exporter(); @ISA = qw(Exporter); @EXPORT = qw(AUTOLOAD); } sub AUTOLOAD() { my $subroutine = $AUTOLOAD; $subroutine =~ s/.*:://; $callme = 'Genesis::'.$subroutine; &{$callme}; } END {} return 1;

Then I'm using a package that I have called Genesis to read a datafile...

package Genesis; BEGIN { use Exporter(); @ISA = qw(Exporter); @EXPORT = qw(&readdatafile); } ################## sub readdatafile { ################## open(FILE, "$datadir/data.dat" ); @thedata = <FILE>; close(FILE); } END {} return 1;

variables.pl actually reads a data file for the different values, but for example, assume this simply reads...

$datadir = "path/to/datafiles"; return 1;

Finally, script.cgi 'requires' variables.pl, 'uses' Autoload and then executes 'readdatafile();'

That is roughly that, so hopefully it will give you the idea of what I'm trying to do?

Floyd