[thechat] Perl arrays

Chris Marsh chris at ecleanuk.com
Tue Feb 18 07:21:00 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




More information about the thechat mailing list