Actually, this is a function that takes a passed in key name and value and
matches them up. the $theName variable is for some presentation code.
I need a list that looks like :
%hash = (
"field1" => "Bob",
"field2" => "Smith",
);
I init the hash with an $arr_criteria_hash(); line
As for the for loop, well, I may get that advanced some time.
Is there an advantage to using for loops over while loops?
-----Original Message-----
From: John Edwards [mailto:[EMAIL PROTECTED]]
What is this ...
---
sub ShowCriteria { #($theKey, $theValue, $theName) {
$arr_criteria_hash{@_[0]} = @_[1];
...
}
---
All about?? You won't get blank keys. You don't need to create the hash
before you use it, Perl will handle that. You could do it like this
$value = 50;
$hash{"key"} = $value;
$hash{"key2"} = $value;
That will give you a hash which looks like this
%hash = (
"key" => 50,
"key2" => 50,
);
To read the values back out of the hash
foreach $key (sort keys %hash) { # The sort will return the keys in the hash
sorted
print "$key => $hash{$key}\n";
}
You don't need a while loop to read it.
Using your code, you could do something like
foreach $field (keys %arr_criteria_hash) {
$newText = " $field like '%$hash{$field}%'";
...
}
But if what you've got is working...
John
-----Original Message-----
From: Bradshaw, Brian [mailto:[EMAIL PROTECTED]]
Sent: 17 September 2001 17:07
To: [EMAIL PROTECTED]
Subject: RE: hash assignment question
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]