[thelist] [thechat] Perl arrays

Chris Marsh chris at ecleanuk.com
Tue Feb 18 07:24:04 CST 2003


Dear all

I have the following loop in Perl:

while (($key, $value) = each(%query)) {
	@numkey = split("\x1c", $key);
	$i = $numkey[0];
	$key = $numkey[1];
	$result .= "<br />$i  -- $key -- $value\n";
}

When I print $result, I get the results that I would expect, so I know
that my values are correct. However, what I want to do is have an array,
@windows, and populate $windows[$i] with an unnamed hash of {$key} =
$value throughout the loop thus:

while (($key, $value) = each(%query)) {
	@numkey = split("\x1c", $key);
	$i = $numkey[0];
	$key = $numkey[1];
##Pseudocode
	$record = \$windows[$i];
	$record{$key} = $value;
##Pseudocode
	undef $record;
}

This, however, is not doing what I want. I suspect I am doing something
rather basically wrong. If I have explained myself adequately can anyone
tell me how I should achieve this?

TIA

Regards

Chris Marsh

___________________________________
thechat mailing list: We promise not to argue about diets anymore...
although that could be a lie
thechat at lists.evolt.org
http://lists.evolt.org/mailman/listinfo/thechat
http://lists.evolt.org/thechatarchive/
____
Please support the community that supports you. Give your bit to
evolt.org at: http://evolt.org/help_support_evolt/




More information about the thelist mailing list