in reply to Re: using main package variables within a module
in thread using main package variables within a module
Shop.pm#!/usr/bin/perl -wT use strict; use lib '/home/4220/straitwa/www.straitway.net/shop_34/lib'; use Shop; my ($conf); #open the config file and parse it unless ($conf = do ('/home/4220/straitwa/www.straitway.net/shop_34/con +f.pl')) { die ("Could not open config file"); } Shop::db_connect;
conf.plpackage Shop; use strict; use Exporter; use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); $VERSION = 1.00; @ISA = qw(Exporter); @EXPORT = (); @EXPORT_OK = qw(db_connect); sub db_connect { print $conf->{'db_database'}; } 1;
What I'm wanting is the module Shop.pm to use the data in conf.pl, but I'm getting the error message{ db_database => 'straitway_1', }
Global symbol "$conf" requires explicit package name at /home/4220/str +aitwa/www.straitway.net/shop_34/lib/Shop.pm line 13. Compilation failed in require at ./test.pl line 4. BEGIN failed--compilation aborted at ./test.pl line 4.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: Re: using main package variables within a module
by mfriedman (Monk) on Jun 17, 2002 at 18:11 UTC |