my $val; my $stmt = q{$val = (defined $ENV{HOST} ? $ENV{HOST} : 'sqlhost')}; eval $stmt; if ($@) { print $@, "\n"; } else { print $val, "\n"; }