[EMAIL PROTECTED] wrote:
> Mr. Shawn H. Corey wrote:
>> On Sun, 2008-09-21 at 09:59 -0700, Ron Bergin wrote:
>>>> #!/usr/bin/perl
>>>> #
>>> You're missing 2 very important pragmas that should be in every script
>>> you write.
>>>
>>> use warnings; #
>>> use strict;   # forces you to declare your vars prior to their use.
>>>
> [snip]
>>> my $ntop = 10;
>>> my (%quad, %port);
>>>
>> my %quad = ();
>> my %port = ();
>>
>> __END__
>>
>> You should always set your variables to a known value.  perl will clear
>> them when it first starts, but other interpreters like mod_perl do not;
>> they re-use the data space as-is for efficiency.  You could end up with
>> data from the previous run.
>>
> Hmmm, when did mod_perl become an interpreter in its own right like perl? 
> Someone else with more knowledge than I can correct me if I'm wrong, but as
> far as I know, mod_perl is a linking/binding of the perl interpreter with the
> apache web server.

Yes. mod_perl keeps a perl interpreter running continuously and saves individual
scripts as compiled subroutines in separate packages. For the most part it is
transparent, but suffers from everything that arises from your code being a
subroutine, primarily that any subroutines become nested ones and common
variables can become trapped as part of an unintended closure.

Certainly there is no point in emptying hashes (or arrays) at declaration as
Shawn proposed.

HTH,

Rob

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to