use strict; my $pre; BEGIN { my $closure; our $our_var; use vars qw/$vars/; if (eval {require CGI::Safe} ) { CGI::Safe->import(); $closure = CGI::Safe->new; $vars = CGI::Safe->new; $pre = CGI::Safe->new; $our_var = CGI::Safe->new; } else { $< = $>; delete @ENV{qw(IFS CDPATH ENV BASH_ENV SHELL PATH)}; require CGI; CGI->import( qw/ :standard / ); $CGI::DISABLE_UPLOADS = 1; $CGI::POST_MAX = 512 * 1024; $closure=CGI->new; $vars=CGI->new; $pre=CGI->new; $our_var=CGI->new; } sub get_obj { return $closure }; } my $q = get_obj(); printf "object in 'closure' method is of class %s\n", ref ($q); printf "object in 'usr vars' method is of class %s\n", ref ($vars); printf "object in 'my' method is of class %s\n", ref ($pre); #printf "object in 'our' method is of class %s\n", ref ($our_var);