in reply to Calling a function from within a HERE doc?
I don't like the import interface, I think you should just call a tie a tie, but you can just use tie with the module without any changes.
(Be sure to have at least one more line under "END")use Interpolation; tie my %EVAL, Interpolation => 'eval'; # or: tie my %EVAL, Interpolation => sub { shift }; print <<"END"; The sum of 3 and 4 is $EVAL{3+4}. END
The key to how this works is that an index to a hash or an array is always interpreted as perl code. Next, a tied hash is used to execute an associated function, instead of actually fetching a hash value out of somewhere.
|
|---|