in reply to Search an array for a pair of matching elements

Hashes are much better if you're going to be doing more than one or two searches, but here you are:
use strict; my @array=("host1","user1","info1","host2","user2","info2"); my $host = "host2"; my $user = "user2"; for (my $i = 0; $i < $#array; $i += 3) { if ($array[$i] eq $host && $array[$i+1] eq $user) { print $array[$i+2]; last; } }