S
Sebastien B.
I'm trying to figure out how to use/make simple global vars.
Since I have multiple scripts that connect to database, I want to use a
seperate file that does the connection and call it in the other scripts; so
something like:
dbiconnect.pl:
use strict;
use DBI;
my $db=dbi_connect.....
1;
and then in the scripts:
use strict;
require 'dbiconnect.pl';
my $somevar=$db->select(...);
problem is that $db isn't global; how do I make it global? Do I need to make
the first script into a pakage? How? (tried it didn't work). None of the
docs are clear on global (cross-file) vars specifically.
Since I have multiple scripts that connect to database, I want to use a
seperate file that does the connection and call it in the other scripts; so
something like:
dbiconnect.pl:
use strict;
use DBI;
my $db=dbi_connect.....
1;
and then in the scripts:
use strict;
require 'dbiconnect.pl';
my $somevar=$db->select(...);
problem is that $db isn't global; how do I make it global? Do I need to make
the first script into a pakage? How? (tried it didn't work). None of the
docs are clear on global (cross-file) vars specifically.