Andrew Gaffney wrote:

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?

perldoc -f ref


sub dohicky {
  for(@_) {
    if(ref($_) eq 'ARRAY') {
   # process as an array ref
    } elsif(ref($_) eq 'HASH') {
   # process as a hash ref
    } else {
   # process non HASH/ARRAY REF
    }
  }
}

HTH

Lee.M - JupiterHost.Net


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to