sub new { my $class = shift; my $self = {}; my %childs; $self = { _handle => undef, _childs => \%childs, waitforchilds => '120', maxchilds => '10', mhandle => undef, }; bless($self,$class); if (@_){ my $hash_ref = shift; if ( ref($hash_ref) eq "HASH"){ while ( my ($k,$v) = ( each %{ $hash_ref } ) ){ $k = lc $k; $v = lc $v; if ( exists $self->{$k} && ! ($k =~ m/^\_/) ){ #is a valid config setting and is NOT a private method my $method = "set_".$k; $self->$method($v); #call appropriate setter method }else{ warn("$0:WARNING: skipping unsupported configuration setting $k => $v in hash_ref $hash_ref\n"); } } }else{ die("$0:ERROR: argument passed to method 'new' must be reference to a hash.\n"); } } return $self; } sub set_mhandle { my $self = shift; if (@_){ my $handle = shift; $self->{mhandle} = $handle; } return $self->{mhandle}; }