in reply to Re: Understanding this line of Code
in thread Understanding this line of Code
Notice how many times the word 'assume' crops up in davorg's excellent explanation? This is a place where ref() can be your friend, if only while debugging this problem. Try testing the various references to see if they are, in fact, array or hash references, like this:
my $mystery_ref = exec_select($sql); my @temp_array = (); if (ref($mystery_ref) eq 'ARRAY') { @temp_array = @{$mystery_ref}; } else { print "Hey! I didn't get the array reference I expected, rather i +t is: ", ref($mystery_ref), "\n"; }
If exec_select() returns an array reference, then you'll end up with that array in @temp_array, otherwise, you'll get a warning, telling you what kind of a reference it is.
|
|---|