in reply to Re^4: How to simulate a preprocessor macro without one?
in thread How to simulate a preprocessor macro without one?
By using overload and overloading q for the constant string parts and the "."-operator for the string concatenations in between.
Cheers Rolf
UPDATE: If this whole thread is just about interpolating method-calls in strings/templates, you should consider the De/Ref-trick with @{[...]} :
perl -e ' {package test; sub test {return "test"}}; $a=[]; bless $a, test; print "@{[$a->test]}" '
please note: here $a->test is called in list context, for scalar context use ${\$a->test} !
UPDATE2: After rereading overload I have the impression that overloading "" might be the approach to overload qq ... but this might also affect all other possible stringifications...(!?!)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: How to simulate a preprocessor macro without one?
by ikegami (Patriarch) on Feb 09, 2010 at 18:14 UTC | |
|
Re^6: How to simulate a preprocessor macro without one?
by AriSoft (Sexton) on Feb 09, 2010 at 21:47 UTC | |
by LanX (Saint) on Feb 09, 2010 at 22:06 UTC | |
by AriSoft (Sexton) on Feb 13, 2010 at 15:04 UTC |