Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
If you have time please take a look at the following code and answer the commented question.
Thanks!
eval { my $foo = new SomeClass; $SIG{__WARN__} = sub { die @_ }; $foo->initialize; $foo->run; }; if ($@) { print "content-type: text/html\n\n$@"; exit; } package SomeClass; sub new { bless { }, shift; } sub initialize { my $self = shift; require CGI; $self->{cgi} = new CGI; return $self; } sub run { my $self = shift; SomeOtherClass::SomeSub($self); # Is there any other way of sendin +g $self to SomeOtherClass without doing it this way? Note: I know I c +ould use @IAS and make SomeOtherClass a SomeClass but I'd rather not +create a new instance of the cgi module if it can't be helped. } package SomeOtherClass; sub SomeSub { my $self = shift; print $self->{cgi}->header, 'Hello World!'; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Passing self from class to class?
by dws (Chancellor) on Aug 28, 2002 at 22:57 UTC | |
|
Re: Passing self from class to class?
by Ovid (Cardinal) on Aug 28, 2002 at 23:05 UTC | |
|
Re: Passing self from class to class?
by adrianh (Chancellor) on Aug 28, 2002 at 22:49 UTC | |
|
Re: Passing self from class to class?
by Anonymous Monk on Aug 28, 2002 at 23:06 UTC | |
by adrianh (Chancellor) on Aug 29, 2002 at 00:09 UTC | |
by Anonymous Monk on Aug 29, 2002 at 00:57 UTC | |
by dws (Chancellor) on Aug 29, 2002 at 01:13 UTC | |
by Anonymous Monk on Aug 29, 2002 at 01:51 UTC | |
by adrianh (Chancellor) on Aug 30, 2002 at 07:09 UTC |