How could I overload the qq operator?
By using overload and overloading q for the constant string parts and the "."-operator for the string concatenations in between.
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...(!?!) |