Reputation: 23
$m = 'this_is_m';
$this_is_m = 'this_is_m_not_full :(';
$this_is_m_full = 'this_is_m_FULL!! :D';
print ${$m};
(Hi first :P) Outputs:
this_is_m_not full :(
Any idea how to output this_is_m_FULL!! :D
using $m
??
What I've already tried:
print $"{$m}_full";
print $'{$m}_full';
print $'$m_full';
print ${$m}_full';
None worked... Thanks in advance,,
Upvotes: 1
Views: 88
Reputation: 416
The following should work:
print ${$m.'_full'};
This is because the string inside the braces will get evaluated first, becoming
print ${'this_is_m' . '_full'}
-> print ${'this_is_m_full'}
-> print $this_is_m_full
Take a look at this manual page if you want more information on this.
Upvotes: 1
Reputation: 9627
The solution would be:
print ${$m . '_full'};
But that feels very hackish.
Upvotes: 2
Reputation:
To get your desired output, you need to do the following:
print ${$m . "_full"};
Upvotes: 2