in reply to Re: Re: User Existance?
in thread User Existance?

Probably a better way to do this, but here's one way:

Update So getpwnam is faster? Ok...

my $username = "usernamehere"; print "Duplicate!\n" if getpwnam($username);
my $username = "user1"; while (<DATA>) { chomp; my @info = split ","; foreach (@info) { print "Duplicate!\n" if /\A\Q$username\E\z/ } } __DATA__ user1 user2 user3 user4 user5,pass5,email5,ip5 user5,pass5,email5,ip5 user5,pass5,email5,ip5 user5,pass5,email5,ip5 user5,pass5,email5,ip5

Replies are listed 'Best First'.
Re: Re: Re: Re: User Existance?
by Anonymous Monk on May 17, 2003 at 20:37 UTC
    why am i getting an error when trying to run this?
    if getpwnam($username) { $message = $message.'<p>The Chosen Username Already Exists.</p>'; $found_err = 1; }
      You need parentheses around the conditional statement for the if...
      if (getpwnam($username)) { $message = $message.'<p>The Chosen Username Already Exists.</p>'; $found_err = 1; }