package Foo; use strict; use warnings; use Log; my $log = Log->get_logger(); sub new { my $class = shift; my $self = {}; return bless($self, ref($class) || $class); } sub printNum { my ($self, $num) = @_; my $correct_num = 4; if ($num != $correct_num) { $log->writeError("I got a $num instead of a $correct_num!"); } } 1;