I want to interpolate hash reference to string, but this method is not working.
How does one interpolate $self->Test->{text}
?
# $self->Test->{text} contains "test 123 ok"
print "Value is: $self->Test->{text} \n"; # but not working
output:
Test=HASH(0x2948498)->Test->{text}
Method calls won't get interpolated inside double quotes, so you end up with the stringified reference followed by
->Test->{text}
.The simple way to do it is to take advantage of the fact that
print
takes a list of arguments:You could also use concatenation:
You could also use the tried-and-true
printf
Or you can use this silly trick: