package MHE;
use Data::Dumper;
##################################################
use Moo;
use Sub::Quote;
my $args = ();
has heartbeat => (
is => 'ro',
default => sub { $args->{heartbeat} || 10; }
);
##################################################
# End of oo setup
##################################################
sub checkArgs
{
my ($self, $args) = @_;
pod2usage( -msg => "No IP address specified\n", -verbose => 1 )
unless $args->{ip};
}
1;
####
package CRANESWL;
use Moo;
extends 'MHE';
has type => (
is => 'ro',
default => 'CRANESWL',
);
##################################################
# Handle incoming messages
##################################################
# hash to define what sub to call dependant upon what msg type
my $msgTypes = {
DUM => \&handleDUM;
};
1;
####
#!/usr/bin/perl -w
use FindBin qw($Bin);
use Getopt::Long;
use strict;
# Set Library path for MHE modules
use lib "$Bin/../lib";
use MHE;
my $opts = {
};
GetOptions($opts,
'type:s',
);
# Use the object dependant upon the requested Type
eval "use MHE::$opts->{type} qw(sendHeartbeat)";
my $mhe = $opts->{type}->new;
$mhe->checkArgs($opts);