How to check data type in @_ ?

2003-07-21 Thread LI NGOK LAM
I am going to write a sub accept different types of data type.
My interface is some what like this :

$ret = mySub ( \%hash );
$ret = mySub ( [EMAIL PROTECTED] );
$ret = mySub ( \$calar );
$ret = mySub ( \Sub );
$ret = mySub ( $calar );
$ret = mySub ( %hash );
$ret = mySub ( @rray );

Is there anyway I can check what is the data type 
for each element inside @_ ?

TIA

RE: How to check data type in @_ ?

2003-07-21 Thread Bob Showalter
LI NGOK LAM wrote:
 I am going to write a sub accept different types of data type.
 My interface is some what like this :
 
 $ret = mySub ( \%hash );
 $ret = mySub ( [EMAIL PROTECTED] );
 $ret = mySub ( \$calar );
 $ret = mySub ( \Sub );
 $ret = mySub ( $calar );
 $ret = mySub ( %hash );
 $ret = mySub ( @rray );
 
 Is there anyway I can check what is the data type
 for each element inside @_ ?

Each element of @_ is a scalar. If you want to know whether that scalar is a
reference to something, use the ref() function.

When you call mySub(%h1, %h2), all the key/value pairs in %h1 and %h2 are
flattened into a single list and assigned to @_. There is no way to tell
that two separate hashes were passed or where one ends and the next one
begins. To achieve this you need to pass hash references (explicitly, or
implicitly through the use of prototypes).

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