RE: determining variable types

2003-01-15 Thread Dan Muey
Do you realize you've posted this message three times so far today and I think 
yesterday as well?
Check your mail prog.

 -Original Message-
 From: OROSZI Balzs [mailto:[EMAIL PROTECTED]] 
 Sent: Tuesday, January 14, 2003 3:56 PM
 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,
  Balzs
 
 P.S.: Sorry, if I sent it twice
 
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 

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




RE: determining variable types

2003-01-15 Thread Beau E. Cox
Hi -

 -Original Message-
 From: OROSZI Balzs [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,
  Balzs

 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]




RE: determining variable types

2003-01-14 Thread Toby Stuart


 -Original Message-
 From: OROSZI Balzs [mailto:[EMAIL PROTECTED]]
 Sent: Wednesday, January 15, 2003 10:07 AM
 To: [EMAIL PROTECTED]
 Subject: determining variable types
 
 
 Hello!
 
 Is it possible to get the type of a variable at run time 
 (hash, array, scalar)?
 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...), SCALAR(0x...))?
 Or is there any other way?
 
 Please, answer as soon as you can. I need to know this in short time.
 I greatly apreciate any help.
 Thank you.
 --
 Greetings,
Balzs
 

read the manpage about the 'ref' function

perldoc -f ref


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




Re: determining variable types

2003-01-14 Thread OROSZI Balzs
Hello!

Toby Stuart wrote:

read the manpage about the 'ref' function

perldoc -f ref


Wow. Thanks a lot. You have just saved my life :)
Now I won't need to hack with regexp's.
Thank you.
--
Greetings,
  Balzs


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