perl - How to interpolate hash element via reference returned by a method into a string? -
i want interpolate hash reference string, method not working. how 1 interpolate $self->test->{text}
?
# $self->test->{text} contains "test 123 ok" print "value is: $self->test->{text} \n"; # not working
output:
test=hash(0x2948498)->test->{text}
method calls won't interpolated inside double quotes, end stringified reference followed ->test->{text}
.
the simple way take advantage of fact print
takes list of arguments:
print "value is: ", $self->test->{text}, "\n";
you use concatenation:
print "value is: " . $self->test->{text} . "\n";
you use tried-and-true printf
printf "value %s\n", $self->test->{text};
or can use silly trick:
print "value is: @{ [ $self->test->{text} ] }\n";