I have mused on this several times in the past and finally concluded it is not that easy at all. My best idea was to use
PyXPCOM in conjunction with
pyperl. A project called PlXPCOM used to provide a Perl/XPCOM bridge but this does not appear to be under development.