#!/usr/bin/perl ########################################### # Mike Schilli, 2002 (m@perlmeister.com) ########################################### use warnings; use strict; ########################################### package Building; ########################################### use Log::Log4perl qw(:easy); sub new { my($class) = @_; DEBUG("Create new $class"); bless {}, $class; } ########################################### package Building::NuclearPowerPlant; ########################################### use Log::Log4perl qw(:easy); our @ISA = qw(Building); ########################################### sub temperature { my($self, $temp) = @_; if(defined $temp) { DEBUG("Set temperature to $temp"); $self->{temp} = $temp; $self->is_ok(); } return $self->{temp}; } ########################################### sub is_ok { my($self) = @_; if(defined $self->{temp} and $self->{temp} > 100) { ERROR("I'm exploding!"); return 0; } INFO("OK"); return 1; } ########################################### package Building::Residential; ########################################### use Log::Log4perl qw(:easy); our @ISA = qw(Building); ########################################### sub tv { my($self, $action) = @_; if(defined $action) { DEBUG("Set tv to $action"); $self->{tv} = $action; } INFO("TV is $self->{tv}"); return $self->{tv}; } 1;