in reply to Is it a scalar or a hash?

Try the function isa, as described in perlobj. The test would be
sub foo { isa( $_[0], 'HASH' ) ? _foo_hash( $_[0] ) : _foo_scalar( $_[0] ); }

Dr. Michael K. Neylon - mneylon-pm@masemware.com || "You've left the lens cap of your mind on again, Pinky" - The Brain

Replies are listed 'Best First'.
Re: Re: Is it a scalar or a hash?
by DrZaius (Monk) on May 13, 2001 at 22:43 UTC
    This is assuming you are passing in a hash ref instead of a hash. This is probably the better way of doing it anyway though, as you aren't passing a bunch of stuff around on each subroutine call.
      Polymorphism is generally less stressful if you are passing and polymorphing on references. There really is no uncludgy way to discriminate between a list of two items and a hash, if not passed by reference.
         MeowChow                                   
                     s aamecha.s a..a\u$&owag.print
Re: Re: Is it a scalar or a hash?
by Anonymous Monk on May 14, 2001 at 09:22 UTC
    What if someone passes in a blessed scalar reference from the "HASH" class?
      Then they deserve a severe beating, for naming a class after a built-in datatype.
         MeowChow                                   
                     s aamecha.s a..a\u$&owag.print