use strict; use warnings; use DBI; my @fields = ( qw/ Genus Species Cultivar Common_Name / ); my $field = get_field( @fields ); my $value = get_value( $field ); # Omitted: code to connect to DB my $select_query = qq/ select * from plant where $field = '$value' /; # Omitted: code to execute, fetch and deallocate SQL query sub get_field { # Highly simplified for testing purposes return $_[3]; } sub get_value { print $_[0], ': '; chomp ( my $choice = ); # <- Problem here! return $choice; }