You could use an anonymous subroutine as the hash value for 'text':
%hash = ( "text" => sub { my $color_opt = shift; return <<"TEXTEND", We play the same game again, but with a different proportion of colore +d balls in + Box K (see below). Everything else is the same. <p> You can choose between box U or box K, both containing 100 balls of five different colors. One ball will be drawn from the box you have + chosen. You win $1,000 if a $color_opt ball is drawn. <p> Please select the box of your choice: U or K. If you think both boxes are equally attractive, you can select Indiffe +rent. TEXTEND }, ); print $hash{text}->("blue"); print $hash{text}->("chartreuse");
That way the interpolation is done when you evaluate the hash value (i.e. call the subroutine).
In reply to Re: updating a variable call in a hash table
by shmem
in thread updating a variable call in a hash table
by coopermc
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |