$ perl -MCGI -e 'my $q = CGI->new(); open CGI, "~/foo.txt"; print ref $q;' Can't locate object method "new" via package "IO::Handle" (perhaps you forgot to load "IO::Handle"?) at -e line 1.