I have the following code which needs to be corrected, as defined(@array)
is deprecated in the latest Perl.
my @inputs = (
( defined @{$padSrc-
defined(@array)
has never done what it looks like it does. It always just returns whether @array
is non-empty.
perl5.10.1 -E 'say defined(@foo)' # ""
perl5.10.1 -E '@foo=(); say defined(@foo)' # ""
perl5.10.1 -E '@foo=(42); say defined(@foo)' # "1"
perl5.10.1 -E '@foo=(undef); say defined(@foo)' # "1"
Anywhere that you test defined(@array)
in your code, you can replace it with
@array != 0
or scalar(@array)
and your code will work exactly the same (plus or minus some deprecation warnings).
As if (condition) ...
or (condition) ? expr1 : expr2
or while (condition)
always evaluate condition
in scalar context, the scalar
is optional in these constructions, and you can replace, say if (defined(@foo))
with if (@foo)
.