use strict; use warnings; my $searchfor = "somebody"; my ($login, $pass, $email, $some, $other, $stuff); open PASSWD, ") { if ((split/\|/)[0] eq $searchfor) { chomp; ($login, $pass, $email, $some, $other, $stuff) = split /\|/; last; } print "nomatch: ", (split/\|/)[0], "\n"; } if ($login) { # match was found. 'print' verifies we got the right stuff. print "match found: $login, $pass, $email, $some, $other, $stuff\n"; # do whatever else . . . } #### nobody|nopass|nobody@home.com|some1|other1|stuff1 anybody|anypass|anybody@home.net|some2|other2|stuff2 somebody|somepass|somebody@home.org|some3|other3|stuff3 everybody|everypass|everybody@home.gov|some4|other4|stuff4 #### nomatch: nobody nomatch: anybody match found: somebody, somepass, somebody@home.org, some3, other3, stuff3