in reply to Re: Re: Re: Passing self from class to class?
in thread Passing self from class to class?

If you're trying to simplify access to the CGI object, sharing $self outside of a class hierarchy is an ugly way to do it. You're mixing objects and procedural code, for one thing, in a way that's going to confuse things for others (or perhaps for yourself, after time has passed).

When people read

sub somesub { my $self = shift;
they expect that somesub is a legitimate object method, and not one that has been force-fed a reference to a class that is related only by way of common data members.

If you want to simplify access to a single CGI object, hide it behind a singleton or make it a global. Globals can be misused, but they have their places.

Replies are listed 'Best First'.
Re: Re^4: Passing self from class to class?
by Anonymous Monk on Aug 29, 2002 at 01:51 UTC
    Yeah, I agree now -- I think I'm going to keep the class structure pretty much as is but in the initialize sub make use of CGI globally.