You could also export the variables (in which case @EXPORT_OK is
preferable to @EXPORT).  It still needs to be a global variable, but you
won't need to refer to it with a fully qualified name.

Craig



On Fri, 23 Jun 2000, Perrin Harkins wrote:

> On Fri, 23 Jun 2000, Scott Alexander wrote:
> 
> > package Mf7::Globals;
> > use strict;
> > use vars qw($VERSION);
> >     my (
> >     $imgserver,
> >     );
> > $VERSION = '0.01';
> > sub Initialize_globals {
> > $imgserver = 'http://www.musiciansfriend.com';
> > }
> > 1;
> 
> Okay, this is an easy one.  You are declaring $imgserver as a lexical (my)
> variable.  When Perl finishes executing this file, lexical variables go
> out of scope.  You can fix this by making it a real global like $VERSION,
> either with a use vars or with fully-qualified variable names.  You could
> still use lexicals if you create subroutine closures to provide access to
> them, but I think using globals is simpler.
> 
> > > Incidentally, the MF site is pretty fast.  Is it running on mod_perl now?
> > Yep. Mod_perl and Apache::Registry saved us from having to get a 
> > ton of new hardware.
> 
> You should submit something for the "success stories" and "sites running
> mod_perl" pages on http://perl.apache.org/.  You might get a few free
> clicks for your trouble.
> 
> - Perrin
> 

Reply via email to