in reply to Typeglobs and Symbol tables

Actually, I think maybe you're being too nice to your users. :) If they're using the procedural interface, they can access the object via $CGI::Q like so:
use CGI qw(:standard); $foo->list_params($CGI::Q);

Since the procedural interface uses $CGI::Q behind the scenes, there's no need to do the symbol table piggery-jokery you've got. :)

As princepawn was wondering, it's best to check with the isa() method. For any object $foo, you can check to see if it inherits from or is a certain class by saying $foo->isa('CGI'). It is indeed possible that the user could pass a CGI::Fast object, which is a valid CGI object but will fail ref $cgi eq 'CGI'.

So, my rewrite would be:

package Foo; use strict; use Data::Dumper; sub list_params { my ( $self, cgi ) = @_; my %formdata; defined($cgi) && ref($cgi) && $cgi->isa('CGI') or return 0; foreach my $key ( $cgi->param ) { $formdata{ $key } = _format_vals( [ $cgi->param( $key ) ] ); } Dumper( \%formdata ); }
Note: Code untested.