error() unless $username =~ m< ^ \w+ \z >x; #### my $sth = $dbh->prepare( 'SELECT some,rows FROM your_table WHERE id = ?' ); $sth->execute( int rand $dbh->selectrow_array('SELECT MAX(*) FROM your_table') );