K
kelticeye
Hi, this is my first post to this group.
I was wondering if there is an efficient method in perl for joining
two (properly ordered) arrays of equal length (@arrayA and @arrayB)
into a hash(%hash) so that $hash{$arrayA} = $arrayB.
I need to do this as the first list is part of an incremental query to
a webform, and if the response is as expected (split up with a regex),
this should be proportional to the query and ordered in the same way
as the query.
Presently I do this through a loop, however this is ugly, creating
iterating variables and I feel I am missing a trick (BTW this does
work):-
my %HresHash;
if (scalar(@residuelist) == scalar(@fullH)){
for (my $i = 0; $i < scalar(@fullH) ; $i++){
my $reskey = "res".$fullH[$i]; # this is done as I want
to add it to a global hash later
$HresHash{$reskey}= $residuelist[$i];
}
}
I have looked through the faqs, this group and google for an easy
answer or function, but please let me know if I am wasting your time
as I will appreciate being pointed in the right direction!
I was wondering if there is an efficient method in perl for joining
two (properly ordered) arrays of equal length (@arrayA and @arrayB)
into a hash(%hash) so that $hash{$arrayA} = $arrayB.
I need to do this as the first list is part of an incremental query to
a webform, and if the response is as expected (split up with a regex),
this should be proportional to the query and ordered in the same way
as the query.
Presently I do this through a loop, however this is ugly, creating
iterating variables and I feel I am missing a trick (BTW this does
work):-
my %HresHash;
if (scalar(@residuelist) == scalar(@fullH)){
for (my $i = 0; $i < scalar(@fullH) ; $i++){
my $reskey = "res".$fullH[$i]; # this is done as I want
to add it to a global hash later
$HresHash{$reskey}= $residuelist[$i];
}
}
I have looked through the faqs, this group and google for an easy
answer or function, but please let me know if I am wasting your time
as I will appreciate being pointed in the right direction!