I have the following lines in a script:
my $spec = shift;
if (!defined $spec) {
return ("Invalid specification", undef);
}
$spec = "$spec" // '';
Naturally, I would expect this when I passed undef, return the warning Invalid specificationto the array, and the second element - undef. Instead, the check is passed, and I get a console message warning me about Use of uninitialized value $spec in stringon the next line.
$specis an object with overloading strings and numbers and, unfortunately, is written in such a way that an attempt to verify the likelihood in this particular subprogram (for example if ($spec)) leads to deep recursion and segfault.
While I'm interested in why this is happening, I'm more interested in how to stop it. I want to exclude a warning about the console, preferably without no warnings qw/uninitialized/. Is this possible, and if so, how to do it?
source
share