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 ...
In reply to using modules by maderman
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |