SWIG: fix PERL binding

PERL pollutes the C++ namespace. To work around that the #undef
statements need to be put *before* the %include statements.