How do you determine what type of data a reference points to? I have a function (one in previous post) that can take either an array of scalars or an array of hash references. I want to execute different code based on which one it was. How can I do that?
use the ref() function - perldoc -f ref
sub marshall {
my($thing) = @_; $type = ref($thing);
if ($type eq "ARRAY") {
return(encode_list($thing));
}
elsif ($type eq "HASH") {
return(encode_hash($thing));
}
elsif (!$type) {
return(encode_scalar($thing));
}
else { die("Can't handle $type\n"); }
}http://www.usenix.org/publications/perl/perl12.html
HTH -Sx-
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>
