use strict; my $rowRef = { foo => 'foo value', bar => 'bar value', }; my $rowName = 'bar'; for my $rn ($rowName, '$rowName') { my $rowValue; if (exists $rowRef->{$rn}) { $rowValue = $rowRef->{$rn} } else { $rowValue = ''; }; print "rowRef for '$rn' is '$rowValue'\n"; };