From 1c26f2c1c78895150d8119159712e97f16924941 Mon Sep 17 00:00:00 2001 From: Shiar Date: Sun, 28 Sep 2008 05:06:09 +0200 Subject: [PATCH] screp: postpone loading modules for optional features Load modules at runtime, so they do not need to be installed if they aren't used. --- screp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/screp b/screp index dc24f05..29b7e0b 100755 --- a/screp +++ b/screp @@ -174,7 +174,7 @@ if ($ACTGIF) { binmode $imgfile; select $imgfile; - use GD; + require GD; my $ani = GD::Image->new($head->{width}, $head->{height}); my $bg = $ani->colorAllocate(0, 0, 0); my @plot = ( @@ -216,9 +216,12 @@ if ($ACTGIF) { select STDOUT; } -use Games::StarCraft::DB; +if ($DBGAME or $DBNAME) { + +require Games::StarCraft::DB; my $Db = Games::StarCraft::DB->connect({RaiseError => 1}) or die "No database: $DBI::errstr\n"; + sub findaccount ($) { my ($name) = @_; my $query = $Db->query(q{ @@ -306,6 +309,8 @@ if ($DBNAME) { $Db->commit; } +} + if ($APMSVG) { my @seq; # player => time (s) => actions $seq[$_->[1]][$_->[0] * .042]++ for @$map; @@ -324,7 +329,7 @@ if ($APMSVG) { } BEGIN { unshift @INC, '.' } - use SVG::TT::Graph::TimeSeries; + require SVG::TT::Graph::TimeSeries; my $graph = SVG::TT::Graph::TimeSeries->new({ height => 1200, width => 1600, -- 2.30.0