Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Answer: Is there an isArray() in Perl?

by jacques (Priest)
on May 10, 2005 at 20:22 UTC ( #455747=categorized answer: print w/replies, xml ) Need Help??

Q&A > arrays > Is there an isArray() in Perl? - Answer contributed by jacques

Alternatively, you can use universal.pm
use UNIVERSAL 'isa'; foreach $item (@array) { if (isa($item, 'ARRAY')) { print "We've got an array!!\n"; } }

Replies are listed 'Best First'.
Re: Answer: Is there an isArray() in Perl?
by salva (Abbot) on May 11, 2005 at 10:42 UTC
    UNIVERSAL is available even without use'ing it, so the previous code snippet can be rewritten as:
    foreach $item (@array) { if (UNIVERSAL::isa($item, 'ARRAY')) { print "We've got an array!!\n"; } }
      Correct; the only point of use'ing UNIVERSAL is to import the function(s)...which he does.
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (6)
As of 2020-10-21 08:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (212 votes). Check out past polls.

    Notices?