Just to bring some Perl into this discussion, and because I'm
inherently lazy and don't want to burn time hunting up references
and such if somebody else has already done that work, and
because my own understanding of how firewalls work is sketchy at best:

Has anybody written any firewall-implementing
code in Perl? Open question, this, incorporating a number of
subsidiary questions, like "Can it be done? Is there a reason
(not) to do it?"