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.

#
# Set behaviour
$log="/var/log/cisco.log";
my $log = '/var/log/cisco.log';

$ntop=10;
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,

my() creates a new empty lexical variable so there is nothing for perl to clear.

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.

If mod_perl implements my() differently than perl please let us know.



John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order.                            -- Larry Wall

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


Reply via email to