What you want is what the heavy-OO people call a "singleton". You could write one yourself (WARNING! Untested code!):
package CGI::Single;
our @ISA;
@ISA = ('CGI');
my $instance;
sub instance {
defined $instance or $instance = new CGI;
$instance;
}
1;
Now, say "
$q = CGI::Single->instance" instead of "
$q = new CGI".
Or, CPAN has Class::Singleton, which should let you just say (again, untested!), mixin-style,
package CGI::Single;
our @ISA;
@ISA = qw(CGI Class::Singleton);
1;
with the same use as before.