sub search_item($$$$) { #* # to search for a list of user IDs which match one criteria (ie: eye_clr=1) # searches can only happen with the logged in user # we must not include the logged in user in the search results! # nor should we include those that are banned or security level 888 or higher #* my ($db, $usersRef, $name, $value) = @_; # a DBH && a reference to a list of users to search && the name of the item to search for && the value the named item must be my @searched; # a list of UIDs which match the given name=value pairs my $query = "select ID from users where $name='$value';"; my $resultsRef = sql_execute($db, $query); if ($resultsRef) { if (ref $resultsRef eq "ARRAY") { # we have multiple hits! my @array = @$resultsRef; foreach my $hit (@array) { # $hit is a hash reference. my %hash = %$hit; push @searched, $hash{ID}; } } else { # we only have one hit! my %hash = %$resultsRef; push @searched, $hash{ID}; } } # it is very possible to have an empty "searched" array. # this is totally ok. return @searched; # an array of uid's which matched the specified criteria, minus the logged in user's uid #usage: my @results = search_item($db, \@uList, "eyes", "1"); }