Let me start by saying I haven't programmed in Perl in a LONG time.
Currently trying to get some older code to work that relies on defined with an array.
Code (abridged):
# defined outside the file-reading block
my %refPRE;
# line from a file
@c = split();
if (defined @{$refPRE{$c[0]}})
{
# do stuff
}
Now this won't run like this because of the following error:
Can't use 'defined(@array)' (Maybe you should just omit the defined()?)
Fine, but if I removed the defined then I get the following error:
Can't use an undefined value as an ARRAY reference.
I can see what it's trying to do (if $c[0] is in the $refPRE then do this, else do something else) but I'm not familiar enough with Perl to figure out what the right way to get this to work is. Hoping this is trivial for someone.
if (exists $refPRE{$c[0]} and (ref $refPRE{$c[0]} eq "ARRAY") and @{$refPRE{$c[0]}})