X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?a=blobdiff_plain;f=yarrg%2FCommodsWeb.pm;h=3ad8590fa9313cab26b1b7e225d745a146193e94;hb=f3fdcfd6d9e7d88fbc97f9294c302c338d2500b5;hp=387b0f2326f0d8130cb38194789ecaa784ec987e;hpb=6bf99c50a24be916c7a1d36a1b9705bdd7828f60;p=ypp-sc-tools.web-live.git diff --git a/yarrg/CommodsWeb.pm b/yarrg/CommodsWeb.pm index 387b0f2..3ad8590 100644 --- a/yarrg/CommodsWeb.pm +++ b/yarrg/CommodsWeb.pm @@ -57,22 +57,25 @@ BEGIN { @EXPORT_OK = qw(); } -sub sourcebasedir () { +sub dotperllibdir () { my $dir; for my $dir (@INC) { if ($dir =~ m/\.perl-lib$/) { - $dir= "$dir/.."; - last; + return $dir; } } - defined $dir or - die "no source base dir in @INC"; - return $dir; + die "no appropriate dotperllib dir in @INC"; +} + +sub sourcebasedir () { + return dotperllibdir().'/..'; } sub datadir () { - my $dir= sourcebasedir(); + my $edir= $ENV{'YARRG_DATA_DIR'}; + return $edir if defined $edir; + my $dir= dotperllibdir(); if (stat "$dir/DATA") { return "$dir/DATA"; } elsif ($!==&ENOENT) { @@ -89,7 +92,7 @@ sub ocean_list () { my $datadir= datadir(); if (!@ocean_list) { my $fn= "$datadir/master-info.txt"; - my $f= new IO::File $fn or die $!; + my $f= new IO::File $fn or die "$fn $!"; my @r; while (<$f>) { next unless m/^ocean\s+(\S.*\S)\s*$/;