tags:

views:

25

answers:

1

Possible Duplicate:
Can Perl string interpolation perform any expression evaluation?

I know I can print a variable inside of a string in quotations like:
print "my variable foo = $foo"

Is there a way to do the same for methods? Something like:
print "my method evaluates to $some_obj->someMethod()"

A: 

Can't you just concatenate the output with the string?

Example: print "my method evaluates to " . $some_obj->someMethod()

Drackir
Yup, but I don't want to. I have a function someone else built that accepts exactly one string, and having to feed it data in two steps by first evaluating the method and concatenating it to the string, and only then feeding the new string to my function is both really annoying and feels very unnecessary.
Eli
I don't think your comment makes any sense. You're confusing syntax (the stuff you type) with operation (the stuff Perl does). Remember to always include the context for your question so we can address the right problem instead of the manufactured problem.
brian d foy
Yup, and I want a pony. A magical pony that will read my mind so I don't have to write any code at all would be even better.
Ether