Define ONLY.
Even "xxx $foo xxx" is just syntactic sugar for "xxx" . $foo . "xxx".
I like to use this 'syntactic sugar' (and some more, that's the reason
for this thread).
BTW this is FAQ: "How do I expand function calls in a string?"
I've searched for "method" and "attributes", as my main interest is OO
Perl.
I'll search in future for "function", too.
"
In general, this is fraught with quoting and readability problems, but
it is possible. To interpolate a subroutine call (in a list context)
into a string:
print "My sub returned @{[mysub(1,2,3)]} that time.\n"
"
http://www.perlmonks.org/?node=How do I expand function calls in a string?
this solution has problems with readability (as already noted by the
author).
See also the Interpolate module and Tie::OneOff. (Tie::OneOff was
originally Tie::Simple but was never realeased under that name. Then
someone else released a substancially identical module under the
originl name!).
http://search.cpan.org/~nobull/Tie-OneOff/lib/Tie/OneOff.pm
http://perl.plover.com/Interpolation/manual.html
Thanks for the info, but I'm unable to see how I could process this
string:
return "$self->label: $self->val($attrib)"
is there any stand-alone function available (something like
"stringeval"), which would process the string correctly?
If yes (or if I write my own), is there a way to override the default
string-processing behaviour of perl on a per-package basis?
..