in reply to Extracting password from array

Unless you are only going to do this lookup once per script, you'd be better reading the file once and setting up a hash:

#! perl -slw use strict; use Data::Dump qw[ pp ]; my %db; while( <DATA> ) { chomp; my( $user, $pass, $db, $server ) = split ':', $_; $db{ $user }{ $db } = [ $pass, $server ]; } sub getPass { my( $user, $db ) = @_; return @{ $db{ $user }{ $db } }; } my( $pass, $server ) = getPass( 'fred', 'rocks' ); print "User:fred db:rocks server:$server pas:$pass"; =comment C:\test>junk53 User:fred db:rocks server:quarry pas:derf =cut __DATA__ fred:derf:rocks:quarry barney:yenreb:rocks:quarry wilma:amliw:shopping:mall betty:ytteb:shopping:mall fred:derf:bowling:alley barney:yenreb:bowling:mall wilma:amliw:hair:saloon betty:ytteb:hair:saloon

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"I'd rather go naked than blow up my ass"