sorry I have never came across grep.
You mean I should be looking to do something like:
$sth = $dbh->prepare(q{select username, password from reg
where username = ?});
$sth->execute($testUsername);
| [reply] [d/l] |
grep applies a test to all the elements of a list and creates a subset of the elements that pass the test. Using it in scalar context return the number of elements which passed the test.
However, if you know the username first, I would suggest making the database do the work and re-writing the query to something like this (note that my SQL skills are quite rusty):
$sth = $dbh -> prepare(q{select username, password from reg where user
+name = $testUsername});
Why return a list to Perl and check the entire list for the existence of username when the database can do exactly that? If you're testing a large number of user names, it may make more sense to query the database for a list, and then check the list for the for existence of all the user names(subject to the caution that the database may have been updated during the processing of the list).
emc
Only two things are infinite, the universe and human stupidity, and I'm not sure about the former.
Albert Einstein
| [reply] [d/l] |
But of course using placeholders :)
----------
"Write a wise saying and your name will live forever." - Anonymous
| [reply] |