473,388 Members | 1,340 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,388 software developers and data experts.

Storing an Array in a Hash

Hi,

I'm having a problem storing an array inside of a hash. I'm bringing
in a hash via a reference and I want to assign a value to it. This is what
I'm doing:
push (@{$$node->{ELEMENTS}}, "New value");

(I need to use "push" because this is going in a for-loop)

However, when I run the script, I get the following:

Can't use string ("0") as an ARRAY ref while "strict refs" in use at ......
How do I solve this?

THanks
Jul 19 '05 #1
1 11168
Here is how I put values into a hash of arrays without push() that worked
pretty good with a for loop

$ar = [];

%ref = ( 'ELEMENTS' , $ar );

for ( $x=0; $x < 100; $x++ ) {

$ref->{ELEMENTS}[$x] = "new Value";

}

You can get the reference like this:

$arrayref = $ref->{ ELEMENT }

push( @$arrayref, "new Element" ); # something like that if you need the
push()
"Hale" <ep**@yaho.com> wrote in message
news:uy*******************@twister.socal.rr.com...
Hi,

I'm having a problem storing an array inside of a hash. I'm bringing
in a hash via a reference and I want to assign a value to it. This is what I'm doing:
push (@{$$node->{ELEMENTS}}, "New value");

(I need to use "push" because this is going in a for-loop)

However, when I run the script, I get the following:

Can't use string ("0") as an ARRAY ref while "strict refs" in use at .......

How do I solve this?

THanks

Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: R. Rajesh Jeba Anbiah | last post by:
I could see that it is possible to have hash array using objects like var hash = {"a" : "1", "b" : "2"}; Couldn't still findout how to declare hash array in Array. var arr = new Array("a" : "1",...
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...
5
by: Stijn van Dongen | last post by:
A question about void*. I have a hash library where the hash create function accepts functions unsigned (*hash)(const void *a) int (*cmp) (const void *a, const void *b) The insert function...
9
by: Crirus | last post by:
I have ~200 players on a server... They share the same 512x512 tiles map... Each player have an explored area and a visible area... visible area is given by players's current units and...
8
by: rgparkins | last post by:
Hi I am creating a sign-up process on a web site much like that of a wizard form. I have browsed many sites to look for examples of how to store the entry data, so that the user can go back and...
3
by: Brian | last post by:
I know this is the wrong way to do it, but maybe someone can tell me the right way to do it... I have two different databases that I need to synchronize. The database doesn't have keys exactly,...
2
by: computerboy | last post by:
I am writing this program that takes a number gives it a hash humber and then put the orginal number in the array spot. ex. Enter a number: 32 Hash value is 5 so 32 is placed in the 5th spot of...
5
by: per9000 | last post by:
Hi all, I want to create an encryption program and started thinking about not storing sensitive information in the memory since I guess someone might steal my computer an scan my memory. So I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.