my $command = "/usr/local/mysql/bin/mysql -u anonymous " . "-h my.database.org ". "--execute='show databases'"; open($fh, "$command |") or die "Could not execute $command because $!\n"; @results = <$fh>; @results = grep { /$temp_choice/} @results;