Adding a Constructor
Prev | Chapter 2. Writing a New DLF Converter | Next

## Adding a Constructor

The Lire framework doesn't place any restrictions on your DLF converter constructor. In fact, the constructor isn't used by the framework at all, it will only be used by your DLF converter registration script (the section called “Registering Your DLF Converter with the Lire Framework”).

We will follow perl's convention of using a method named `new` for our constructor and of using an hash reference to hold our object's data.

Here is our complete constructor:

    use Lire::Syslog;

    sub new {
        my $pkg = shift;

        my $self = bless {}, $pkg;

        $self->{syslog_parser} = new Lire::Syslog();

        return $self;
    }

Since our log format is based on syslog, we will reuse the syslog parsing code included in Lire. This is the reason we instantiate a `Lire::Syslog` object and save a reference to it in our constructor.

Prev | Up | Next
Creating the DLF Converter Skeleton | Home | The Meta-Data Methods