in reply to Re^4: accessing values in hash
in thread accessing values in hash

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

Replies are listed 'Best First'.
Re^6: accessing values in hash
by Nevtlathiel (Friar) on Sep 05, 2006 at 10:11 UTC
    But of course using placeholders :)

    ----------
    "Write a wise saying and your name will live forever." - Anonymous

      Now that I know about them, of course.

      emc

      Only two things are infinite, the universe and human stupidity, and I'm not sure about the former.

      Albert Einstein