#col1name and col2name are the names of the columns in the database $hash_ref = { col1name=>"orange", col2name=>"15" }; #### # get whole result set into an array my @rs = @{ $sth->fetchall_arrayref() }; # each element of @rs is a reference to a two-member array #let's map the first elements to the keys of the hash # and the second elements to the values. my %hash = map { $_->[0] => $_->[1] } @rs; #### perl -e 'print "How sweet does a rose smell? "; chomp ($n = ); $rose = "smells sweet to degree $n"; *other_name = *rose; print "$other_name\n"'