Hi -

> -----Original Message-----
> From: OROSZI Balázs [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, January 14, 2003 11:56 AM
> To: [EMAIL PROTECTED]
> Subject: determining variable types
>
>
> Hello!
>
> Is it possible to get the type of a variable at run time?
> Suppose I have $var which may be a ref to a hash, or a ref to an
> array or a
> scalar (maybe a ref to it).
>
> Should I try to hack it out from the address
> (the weird thing, for example ARRAY(0x...))?
> Or is there any other way?
>
> Please, answer as soon as you can. I need to know this in short time.
> Thank you.
>
> --
> Greetings,
>      Balázs
>
> P.S.: Sorry, if I sent it twice
>

Yes.

Use the perl build in function 'ref':

  if(ref $variable eq 'HASH') { ... }

you can use "HASH', 'ARRAY', 'SCALAR' (and other, less common ones).

 if (not ref $variable) { ... means it's not a reference ... }

Refer to the Camel book or perlfunc doc for more details.

Aloha => Beau;



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to