[ale] Organizing data
Fletch
fletch at phydeaux.org
Wed Apr 28 09:35:27 EDT 2004
>>>>> "Jason" == Jason Etheridge <phasefx at magusaptus.com> writes:
Jason> Fletch wrote:
>> Aieeeee, no. You mean: if( ref
>> $a_ref->{$ref}->{$ref2}->{$ref3} eq 'HASH' ) { ## Is hash ref }
>> else { ## Not hash ref
>> }
Jason> Coolness. I knew there had to be a function for that but
Jason> couldn't find it. :D
perldoc perlreftut, perldoc perlref.
Also something someone else pointed me at out-of-band is that the
Scalar::Util module has a `reftype' function that will return the
underlying type even for blessed objects:
reftype EXPR
If EXPR evaluates to a reference the type of the variable refer-
enced is returned. Otherwise "undef" is returned.
$type = reftype "string"; # undef
$type = reftype \$var; # SCALAR
$type = reftype []; # ARRAY
$obj = bless {}, "Foo";
$type = reftype $obj; # HASH
Granted an object would probably count as a value in the situation at
hand this wouldn't be what you'd want, but it's nice to know.
--
Fletch | "If you find my answers frightening, __`'/|
fletch at phydeaux.org | Vincent, you should cease askin' \ o.O'
| scary questions." -- Jules =(___)=
| U
More information about the Ale
mailing list