Dear All, I have sample code below, i am trying print the matching array element values sorted in the hash.
As you would notice only one of the array element "x1259" will print its value "IDT" stored in the hash. Please could you advice how can i get rest of the array elements matched in the hash example "1439" in array element needs to print its value as "IDT", currently its not printing becase the key sorted in hash is "187333591439" . is there a way to do a search the key for the matching array element and print its value ? Ideally i would like get all the array element matched in the hash and print its value. Your inputs are much apprecaited to resolve this. Thanks --------------------------- fullhost.txt 187333591439 IDT e61391 GYX 2041-CX-1 VG 3333494 IDT e55326 xng x1259 IDT -------------------------- my %complex_hash; my @ex = qw / 5326 2041 1391 1439 x1259 /; open my $fh, "<", "fullhost.txt" or die $!; while (<$fh>) { Chomp; my $line = $_; my ($key, $value) split/\t+/,$line; $complex_hash{key} = $value; } for my $element (@ex) { print " $element \t\t\t $complex_hash{$element} \n" } -----------------------------------------------------------------------------