The Perl HL7 toolkit is a Perl API for sending, parsing and receiving HL7 messages, and a pluggable hl7 server. The hl7 server is a reference implementation of the API, but is stable enough to be used in real-life situations. The server is pluggable with your own Perl modules, and can be used to dispatch incoming HL7 messages to, for example, databases, files, etc.
Find the toolkit either on SourceForge
or on CPAN.