There are other ways to do that - you should read up on creating and using modules by doingpackage Private_Stuff; use strict; use CGI::Carp qw(cluck); ### for log_error subroutine use Time::Local; ### for datetime_to_epoch_secs subroutine use vars qw($VERSION @ISA @EXPORT @EXPORT_OK $db_name); require Exporter; @ISA = qw(Exporter AutoLoader); # Items to export into callers namespace by default. Note: do not expo +rt # names by default without a very good reason. Use EXPORT_OK instead. # Do not simply export all your public functions/methods/constants. @EXPORT = qw(); @EXPORT_OK = qw(); $VERSION = '0.01'; $db_name = "Some_Database_Name"; 1; ### end of module ------------------------------------ test.pl ------- use Private_Stuff; print "The database name is ", $Private_Stuff::db_name, "\n";
at a command prompt.perldoc perlmodlib
In reply to Re: storing data in a package/module
by hmerrill
in thread storing data in a package/module
by nmerriweather
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |