Using API Constants

All manifest constants defined in laygodef.h are defined with the same names and values in Laygo.pm. Therefore they can be used in Perl5 in exactly the way they are documented for the C language API. For instance, the C code:

if (state == lgo_STATE_DATA_TRANSFER_XON)
{
    ConnectNotify();
}
else if (state == lgo_STATE_WAITING_FOR_REMOTE_CONFIRMATION)
{
    DisconnectNotify();
}
else if (state == lgo_STATE_OPEN)
{
    OpenNotify();
}

can be written in Perl5 as:

if ($state == STATE_DATA_TRANSFER_XON)
{
    &ConnectNotify();
}
elsif ($state == STATE_WAITING_FOR_REMOTE_CONFIRMATION)
{
    &DisconnectNotify();
}
elsif ($state == STATE_OPEN)
{
    &OpenNotify();
}

For clarity, you may want to prefix the constant names with the package name, even though the use Laygo; statement makes it optional:

if ($state == Laygo::STATE_DATA_TRANSFER_XON)
{
    &ConnectNotify();
}
elsif ($state == Laygo::STATE_WAITING_FOR_REMOTE_CONFIRMATION)
{
    &DisconnectNotify();
}
elsif ($state == Laygo::STATE_OPEN)
{
    &OpenNotify();
}