$found = 0; foreach $i (@indata) { chomp($i); ($username,$password) = split(/\|/,$i); if ($in{'oldname'} eq $username) { $found = 1; do your other checks for data . . . } } if (!$found) { print "You are not registered!"; }