#!/usr/bin/perl package SBL_Config; use strict; use warnings; use diagnostics; use Data::Dumper; my $root_url = "/sbl"; sub new { my $self = {}; $self->{ROOT} = $root_url; $self->{ERROR} = undef; bless($self); return $self; } sub root { my $self = shift; if (@_) { die "SBL_Config::root is read-only"; } return $self->{ROOT}; } sub error { my $self = shift; if (@_) { die "SBL_Config::error is read-only"; } return $self->{ERROR}; } sub check { my ( $self, $q ) = @_; # my $self = shift; # my $q = shift; die "No CGI query passed to SBL_Config::check" if undef $q; print STDERR "q is " . (undef $q ? "undef" : "defined") . "\n"; print STDERR Dumper $q; my $loc; $loc = $q->url() || die "No URL from CGI"; $loc = $q->url(-relative=>1) || die "No relative URL from CGI"; if ($loc != $self->root ) { $self->{ERROR} = "Bad root URL"; return 0; } return 1; }