[Gas] dumb perl question (fwd)

Zachary C.Miller wolfgang at wolfgang.groogroo.com
Fri May 25 11:13:11 CDT 2001


oops, didn't Cc this one to the list.

Zachary C . Miller wrote:
> > The Gas code example has the following section in the main .pm
> > file:
> > 
> >    no strict 'vars';
> >    # Globally defined static (CONSTANT) variables go here. Note that this
> >    # file (and any other use'ed file) is only run at BEGIN time when
> >    # running under mod_perl and so any calculations are done at server
> >    # startup rather than at request time.
> > 
> > this implies that there's a way to make static variables in Perl,
> > which i've heard is the case, but I don't know how to do it.  i
> > hope i will be pardoned for asking here rather than r'g tfm, but
> > how do you make static variables in Perl?
> 
> sorry, there's some confusion there about the meaning of "static".
> 
> I meant "global" when I said "static". I did not mean "having the
> properties of C variables defined with the static keyword.
> 
> I guess I was maybe thinking more of Java's static keyword which is
> for defining class-wide variables (rather than instance variables
> which is the default in java). Of course in Perl all global variables
> are class (package) wide variables as "instance variables" are really
> just keys in a blessed hash rather than real variables.
> 
> Perl has global variables and lexical variables. You could call the
> globals "static" and I did. It is probably not entirely accurate to do
> so.
> 
> Global variables under mod_perl are in some sense like C's "static"
> variables in the sense that they will keep their values even between
> executions. This is however not something you should _ever_ rely on as
> it leads to bad programming practice and bugs. Global variables under
> mod_perl should only be used to hold constant values unless you are
> _sure_ to reinitialize them in the driver .cgi program.
> 
> This has been your confusing clarification for the day. 
> 
> -- 
> Zachary C. Miller - @= - http://wolfgang.groogroo.com/
> Today (Friday, May 25) is Towel Day - http://www.towelday.org








More information about the Gas mailing list