Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I'm having issues accessing a CGI object in the main namespace from within a 'require'-ed file...For instance, this is my main script:
and this is the library file it requires (functions.pl):#!/usr/bin/perl -w use strict; use CGI; use CGI::Carp qw(fatalsToBrowser); require "functions.pl"; # define a hash to contain any "global" objects or variables our %GLOBAL = ( 'query' => '', 'test' => 'foobar!' ); $GLOBAL{'query'} = new CGI; print CGI::header(); outputTest(); outputPOST();
running this as-is throws up an Internal Server Error, which is strange considering i'm using fatalsToBrowser. i'm sure the problem is with the CGI query object, because if I remove the outputPost subroutine, it runs fine.sub outputTest { print $main::GLOBAL{'test'}; } sub outputPOST { print $main::GLOBAL{'query'}->Vars; } 1;
am I just missing something vitally obvious?
Back to
Seekers of Perl Wisdom