Reading docs helps

ethan on 2004-01-16T09:55:39

This morning I added the overloading stuff for the Device::CDROM::Addr objects. I first poked around in the perl source to figure out how to do that until I declared this approach fruitless. All I got were segfaults.

Then - more by accident than on purpose - I stumbled over the OVERLOAD keyword in perlxs. I was delighted to see that there is in fact a defined XS interface to overloading. Nice.

However, xsubpp apparently gets confused when you have several packages in one .xs file. It registered my overload handler into the wrong package (Device::Addr::Format which happens to be the last package in the file). This left my module in an uncompilable state.

So I did a google-search for the OVERLOAD keyword, found nothing. After that, I used google to scan perl5.porters for me and found a short reference to OVERLOAD by John Peacock. This name always triggers Version in my mind so I looked it up on the CPAN and indeed did find a stupendously easy solution to my problem in version.xs.

I'd be a rich chap by now if someone paid me half a Euro (or whatever) each time I solved a problem by looking at other people's code.