473,326 Members | 2,108 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

a hash of arrays

Hi all,
I'm having a problem getting the length of an array that I've put in a
hash here's my code

Expand|Select|Wrap|Line Numbers
  1. $voorwaardehash{$key} = [@getallen];
  2.  
  3.         @lengte = $voorwaardehash{$key};
  4.  
  5.         print "--".$#lengte ."\n";
now this looks fine to me except that ik keeps returning 0 instead of the true length of the array thats at the key
Dec 21 '07 #1
2 1266
KevinADC
4,059 Expert 2GB
Hi all,
I'm having a problem getting the length of an array that I've put in a
hash here's my code

Expand|Select|Wrap|Line Numbers
  1. $voorwaardehash{$key} = [@getallen];
  2.  
  3.         @lengte = $voorwaardehash{$key};
  4.  
  5.         print "--".$#lengte ."\n";
now this looks fine to me except that ik keeps returning 0 instead of the true length of the array thats at the key

You need to use dereferencing syntax because $voorwaardehash{$key} is a reference to an array:

@lengte = @{ $voorwaardehash{$key} };
print scalar @lengte;

or:

print scalar @{ $voorwaardehash{$key} };

or:

$length = @{ $voorwaardehash{$key} };
print $length;
Dec 21 '07 #2
thanx the @{} thing was what I was looking for
Dec 22 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

31
by: Alexis Nikichine | last post by:
Hello, It is common knowledge that arrays can be used as hashtables: var color = ; color = 0xFF0000; color = 0x0000FF;
47
by: VK | last post by:
Or why I just did myArray = "Computers" but myArray.length is showing 0. What a hey? There is a new trend to treat arrays and hashes as they were some variations of the same thing. But they...
22
by: VK | last post by:
A while ago I proposed to update info in the group FAQ section, but I dropped the discussion using the approach "No matter what color the cat is as long as it still hounts the mice". Over the last...
38
by: VK | last post by:
Hello, In my object I have getDirectory() method which returns 2-dimentional array (or an imitation of 2-dimentional array using two JavaScript objects with auto-handled length property - please...
12
by: wxs | last post by:
Many times we have a bunch of enums we have from either different enums or the same enum that will have various numeric values assigned. Rarely will there be collisions in numbering between the...
1
by: sympatico | last post by:
Hi, I am trying to compare 2 images to check if they are exactly identical (in terms of data), I thought this would be quicker than analysing pixels of the images. I have found lots of examples...
21
by: Johan Tibell | last post by:
I would be grateful if someone had a minute or two to review my hash table implementation. It's not yet commented but hopefully it's short and idiomatic enough to be readable. Some of the code...
2
by: Salman | last post by:
How can I use Haspmap in C++ and what will be benefit of hashmap over arrays?
3
by: keithl | last post by:
Hi (again !) I posted a question yesterday just for info on hashrefs which I have read and it makes sense. Putting this into proactive though has now toally confused me ! I have an XML file...
28
by: natarajmtech | last post by:
Hi all, I have defined some array variables a ***************************************** @L=('CTT','CTC','CTA','CTG','TTA','TTG'); @S=('TCT','TCC','TCA','TCG','AGT','AGC'); ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.