From: Eric Wong Date: Sun, 30 Aug 2015 10:12:54 +0000 (+0000) Subject: www: avoid BEGIN block for config loading X-Git-Tag: v1.0.0~955 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=7c9ece10460f53e37f457e85d6d71eaa0c3c86ee;hp=ab8bdfe79cd0b6cac57b4f1cae538c51e8f9c317;p=public-inbox.git www: avoid BEGIN block for config loading It fails the syntax check if a user does not have ~/.public-inbox/config setup. Anyways we can safely use ||= on a global since we do not support threads. --- diff --git a/lib/PublicInbox/WWW.pm b/lib/PublicInbox/WWW.pm index a01271b1..e6eec3d6 100644 --- a/lib/PublicInbox/WWW.pm +++ b/lib/PublicInbox/WWW.pm @@ -17,12 +17,10 @@ use constant SSOMA_URL => 'http://ssoma.public-inbox.org/'; use constant PI_URL => 'http://public-inbox.org/'; our $LISTNAME_RE = qr!\A/([\w\.\-]+)!; our $pi_config; -BEGIN { - $pi_config = PublicInbox::Config->new; -} sub run { my ($cgi, $method) = @_; + $pi_config ||= PublicInbox::Config->new; my %ctx = (cgi => $cgi, pi_config => $pi_config); if ($method !~ /\AGET|HEAD\z/) { return r(405, 'Method Not Allowed');