chuckd has asked for the wisdom of the Perl Monks concerning the following question:
I have a line of code like this:
$datfield{"text"} = gettext($text)
where $text is a string of text being passed into gettext().
the function gettext returns a reference to the text like return \$text. how can I dereference the text value returned from gettext and place it into the hash value in one line. I don't want to have to split the lines.
Comment on dereferencing values returned from functions
use Data::Dump 'pp'; # for display purposes only
my %datfield;
my $text = "some stuff";
$datfield{"text"} = ${ gettext($text) };
pp \%datfield;
sub gettext {
my $text = shift;
return \$text;
}
__END__
{ text => "some stuff" }