package My::CGI; use strict; use CGI; sub new { my $class = shift; my $foo = 'bar'; my $q = CGI->new(); my $self = { foo => "$foo", cgi => "$q", }; return bless $self, $class; } package main; use strict; my $q = My::CGI->new(); print $q->{foo}, "\n"; print $q->{cgi}->a({href=>'http://foo.bar'},'some link'),"\n"; __END__ yields: bar Can't locate object method "a" via package "CGI=HASH(0x80f8a20)" at ./foo.pl line 26.