Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: How to compare an empty key with another empty key in associative array

by Rudolf (Monk)
on Oct 24, 2012 at 11:50 UTC ( #1000615=note: print w/ replies, xml ) Need Help??


in reply to How to compare an empty key with another empty key in associative array

$b = {}; is not an associative array. An array containing other arrays may look something like this:

my @two_d_array = ([$x,$y,$z],[1,2,3],['a','b','c']);

To see if an array is empty, you can check it's scalar value for contents.

my $elements = scalar(@two_d_array);

UPDATED: Associative array is considered a hash in Perl, (thanks choroba),


Comment on Re: How to compare an empty key with another empty key in associative array
Select or Download Code
Re^2: How to compare an empty key with another empty key in associative array
by choroba (Canon) on Oct 24, 2012 at 11:51 UTC
    "Associative array" is "hash" in Perl lingo, not an array.
    لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1000615]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (9)
As of 2015-07-02 21:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (45 votes), past polls