maderman has asked for the wisdom of the Perl Monks concerning the following question:
where the contents of sub connectdb are contained in a seperate file SUBS.pm. The contents of that file are:package SUBS; require 'SUBS.pm'; use strict; my($dbh, $sth, $fault_no, @dbinfo, $base, $line); $base = "/path/to/loginfile"; &connectdb();
Now when I run db.cgi, I'm getting the following for all the variables in &connectdb:package SUBS; require Exporter; @ISA = qw(Exporter); @EXPORT = qw( &connectdb ); use strict; #Open the Oracle database: if (!defined(open(DBINFO, "$base/dbinfo"))) { die "Can't open dbinfo.\n"; } while(defined($line = <DBINFO>)) { chomp($line); push @dbinfo, $line; } close(DBINFO); $dbh = DBI->connect($dbinfo[0],$dbinfo[1],$dbinfo[2],$dbinfo[3], { RaiseError => 1, AutoCommit => 1} ); }
So my question is this: if I have declared global variables in db.cgi, why can't SUBS.pm see them? Many thanks in replying... Stacy.Global symbol "$var" requires explicit package name at SUBS.pm line ...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: using modules
by Fletch (Bishop) on Nov 09, 2001 at 17:26 UTC | |
by maderman (Beadle) on Nov 09, 2001 at 17:35 UTC | |
|
Re: using modules
by davorg (Chancellor) on Nov 09, 2001 at 17:33 UTC | |
by maderman (Beadle) on Nov 09, 2001 at 20:24 UTC | |
by davorg (Chancellor) on Nov 09, 2001 at 20:35 UTC | |
by maderman (Beadle) on Nov 09, 2001 at 20:44 UTC | |
|
Re (tilly) 1: using modules
by tilly (Archbishop) on Nov 09, 2001 at 20:32 UTC |