Yes, that message is correct:
$ perl -Mwarnings -Mdiagnostics -e '@array = (1,2,3); print defined(@a +rray)' defined(@array) is deprecated at -e line 1 (#1) (D deprecated) defined() is not usually useful on arrays because i +t checks for an undefined scalar value. If you want to see if the array is empty, just use if (@array) { # not empty } for example.
Your code:
my $tSida = $sida + 1; if ((@annots) || (defined @{$links{'-1'}}) || (defined @{$links{$tSida +}})) { $sidObjekt .='/Annots ' . mergeLinks() . ' 0 R'; }
Would be better written as...
my $tSida = $sida + 1; if( @annots || @{$links{'-1'}} || @{$links{$tSida}} ) { $sidObjekt .= '/Annots ' . mergLinks() . ' 0 R'; }
Your use of defined is presumably to determine if the array ref stored in $links{'-1'} contains values. If instead you want to determine if $links{'-1'} exists, use exists. If you want to see if $links{'-1'} is defined, use defined without dereferencing the element. And if you want to see if it contains an anonymous array, you can use ref or Scalar::Util::reftype()
Dave
In reply to Re: Define(@array) is Deprecated
by davido
in thread Define(@array) is Deprecated
by PilotinControl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |