in reply to Extracting password from array

split
while (<$fh>) { chomp; my ($user,$passwd,$db,$server) = split /:/; if ($db eq $desired_db && $user eq $desired_user) { ... last; } }

Replies are listed 'Best First'.
Re^2: Extracting password from array
by robotball (Initiate) on Mar 26, 2010 at 17:48 UTC
    Thanks. I guess I was trying to do to many tricks thinking this could be a one-liner like if you were to use shell.
      I'd like to see this shell solution

        Untested

        egrep "^$1:[^:]*:$2:" | cut -d':' -f2
        Shell solution would be PASSWD=`cat password_file | grep $database | grep $user | cut -d: -f2`