my $username = SomeSubToGetUsername; my $check = getpwnam($username); if ($check) { # account exists ... } else { # account does not exist ... }