Re: Is an Array

2004-06-15 Thread James Edward Gray II
On Jun 15, 2004, at 2:24 PM, Angie Ahl wrote:
Hi
Howdy.
Scouring the books to try and find this, but it's evading me.
How can I test whether something is an array.
For some definition of "something" that includes references, use ref(). 
 :)

ie I have a hash and some values are anon arrays and some are strings. 
I want to test to see whether one is an array and then traverse it.
if ( ref($some_hash{might_be_array_ref}) eq 'ARRAY' ) {
# ...
}
Hope that helps.
James
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>



Re: Is an Array

2004-06-15 Thread Jeff 'japhy' Pinyan
On Jun 15, Angie Ahl said:

>ie I have a hash and some values are anon arrays and some are strings.
>I want to test to see whether one is an array and then traverse it.

  if (ref $hash{$key}) {
# do something with @{ $hash{$key} }
  }

perldoc -f ref

-- 
Jeff "japhy" Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
CPAN ID: PINYAN[Need a programmer?  If you like my work, let me know.]
 what does y/// stand for?   why, yansliterate of course.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Is an Array

2004-06-15 Thread Angie Ahl
Hi
Scouring the books to try and find this, but it's evading me.
How can I test whether something is an array.
ie I have a hash and some values are anon arrays and some are strings. 
I want to test to see whether one is an array and then traverse it.

Cheers
Angie
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>