The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.




The Net-HL7 package is a simple Perl API for creating, parsing sending and receiving HL7 messages. To create an empty HL7 message object, do:

and add segments like:

For details, please consult the man pages of each specific class, or consult the generated API docs on You might also check the test files in the 't' directory for examples.

The Net::HL7 class is only used for documentation purposes (the stuff you're reading right now), to set HL7 configuration properties such as control characters on a global level and to provide a version number of the package to the Perl installation process. This can be used in a 'require' statement, or to create a dependency from another Perl package.


Some HL7 properties may be altered on a global level. Altering the variable makes it changed for this remainder of the lifetime of this Perl process. All HL7 messages will use the values provided here, unless something is changed in the MSH segment concerning these properties.


Separator for segments within a message. Usually this is \015.


Field separator for this message. In general '|' is used.


HL7 NULL field, defaults to "". This is therefore different from not setting the fields at all.


Separator used in fields supporting components. Usually this is the '^' character.


Separator for fields that may be repeated. Defaults to '~'.


Escape character for escaping special characters. Defaults to '\'.


Separator used in fields supporting subcomponents. Usually this is the '&' character.


This is the version used in the MSH(12) field. Defaults to 2.2.