Hi Stephen,
John is saying that you need to declare them, not initializing them.
Declaring them means that you're saying that variable will be used;
initializing them means giving them a value. With "use strict", you
need to define them before you give them a value...which is a good
sanity check.
Declaring them (locally) is to do:
my $x;
Giving it an initial value (any value, not just "0") would be:
$x = 123;
You could very well do them on separate lines; what John suggested is to
do it all in one line:
my $x = 123;
which is of course, ok. Anyway, the point is, you need to declare them
with "my" first before you use them. With respect to your reply below,
it doesn't matter whether you gave it a value of 0 or some other
value...there is no rule on what an initial value should be...whatever
fits your situation. But, you need to declare it.
Ray
Stephen Reese wrote:
John is right.
You should always 'use strict' at the begin of the scripts.
Here you didn't declare the variables, so you got the errors.
You could declare them with:
my $x = ...;
my $foo = ...;
For Perl's variable scope, see this:
http://perl.plover.com/FAQs/Namespaces.html
Jeff, are they not defined here:
$x=$6;
$srca{$2}+=$x;
$foo=sprintf("%16s -> %16s %3s port %-6s",$2,$4,$1,$5);
$moo=sprintf("%3s port %-6s",$1,$5);
$quad{$foo}+=$x;
$port{$moo}+=$x;
or must they be set to something like 0?
Thanks
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/