In diagnosing some error problems, I made up a TIE module for printing. It works quite well, but does "wierd things" in one instance. The routine that is called says:
Use of uninitialized value in split at <routine/line> during global destruction.
The code is pretty simple (reconstructed a bit):
sub fool
{
my @vals;
my $n;
my $i;
while (@_)
{
@vals = split /(\n)/, (shift); # Error happens here
$n = @vals;
for ($i = 0; $i < $n; $i++)
{
print "The value is: $vals[$i] \n"; # Or similar action
}
}
}
My question: how do I detect that this error is GOING to happen with the called arguments (in this case to the 'fool' routine) so I can print out a more intelligent error message?
Is there any way I can "produce" this same error message using the 'fool' routine as shown above. It would "enlighten" me quite a bit.