my $instance;
sub new
{
my ($class, $loglevel) = @_;
$instance ||= do {
print "$class $VERSION started with loglevel $loglevel\n"
if $loglevel >= 3;
bless { _usersetloglevel => $loglevel }, $class;
};
}
####
my $network_connection = NetworkConnection->new;
$network_connection->set_logger( PrintToScreen->new(3) );
my $database_connection = DatabaseConnection->new;
$database_connection->set_logger( PrintToScreen->new(1) );
####
use strict;
use warnings;
sub multiply_integers
{
die "two positive integers!\n"
if @_ != 2
|| grep { not /^[1-9][0-9]*$/ } @_;
my ($x, $y) = @_;
return $x if $y == 1;
return $x + multiply_integers($x, $y-1);
}
print multiply_integers(7, 6), "\n";