This is the easy part. If you have never written a Perl module, you can find some tutorials elsewhere [need reference]. Our Perl module will be called Astro::INDI and we can produce a skeleton quite simply. I’m going to be bit picky here and insert POD (plain-old documentation) as I do this. It’s a habit well-worth cultivating.

package Astro::INDI;

=head1 NAME - Astro::INDI

=head1 SYNOPSIS

use Astro::INDI;
my $client = new Astro::INDI('host' => 'localhost', 'port' => 7624);

=head1 DESCRIPTION

Implements the INDI client protocol to facilitate writing INDI clients in Perl.

=head1 EXAMPLES

=cut

use strict;
use Socket;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);

require Exporter;

@ISA = qw(Exporter AutoLoader);

# Items to export into callers namespace by default. Note: do not export
# names by default without a very good reason. Use EXPORT_OK instead.
# Do not simply export all your public functions/methods/constants.
# @EXPORT = qw( );

@EXPORT_OK = qw( );

%EXPORT_TAGS = ( ALL => \@EXPORT_OK );

$VERSION = '0.1';

# Preloaded methods go here.

sub new {
my ($class, %initializer) = @_;
my $self = { 'host' => 'localhost',
'port' => 7624 };
bless $self, ref $class || $class;
foreach my $key (keys %initializer) {
$self->{$key} = $initializer{$key};
}
return $self;
}

=head1 ACKNOWLEDGEMENTS

Elwood C. Downey is the creator of INDI. He wrote the original white-paper, formalized the XML protocol, and
wrote a significant portion of the initial INDI library including the standalone client tools getINDI, setINDI, and
evalINDI.

Jasem Mutlaq wrote a significant portion of the INDI library and oversees the SourceForge project.

Many others have been involved in making INDI a viable project. This includes everyone who has written, helped
write or debug a device driver. Thanks are also due those manufacturers who have provided communications
specifications or source code to control their devices.

=head1 AUTHOR

Roland Roberts (roland AT astrofoto DOT org)

1;
__END__

The only thing we have defined here is a method to create a new object. It’s not a very useful object without some more methods, but those come later. I’ve also added, somewhat presciently at this point, the “use Socket” line. Since the stock INDI server talks via TCP/IP, we’re going to need that.

On to the more interesting parts….