You have to declare your variables with strict and warnings.
e.g. my @records or possibly our @records
This might have been better asked in the chatterbox
| [reply] [d/l] [select] |
From the docs of the strict module:
This generates a compile-time error if you access a variable that wasn't declared via our or use vars, localized via my(), or wasn't fully qualified. Because this is to avoid variable suicide problems and subtle dynamic scoping issues, a merely local() variable isn't good enough. See my in the perlfunc manpage and local in the perlfunc manpage.
use strict 'vars';
$X::foo = 1; # ok, fully qualified
my $foo = 10; # ok, my() var
local $foo = 9; # blows up
package Cinna;
our $bar; # Declares $bar in current package
$bar = 'HgS'; # ok, global declared via pragma
The local() generated a compile-time error because you just touched a global name without fully qualifying it.
Because of their special use by sort(), the variables $a and $b are exempted from this check.
CountZero A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James
| [reply] [d/l] [select] |
Without seeing the code itself it's hard to say, but the first thing I'd check is that everything's declared with "my" (or "our", or whatever is appropriate). Failing that, check that your variables don't go out of scope before you use them. | [reply] |