Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
But since I have many foo like sub's I'd like to do something like...sub foo { my $self = shift; $self->query->param('id'); if (!$id) {return $self->get_id();} #get_id returns a web page that prompts the user for an id #this is all running in mod_perl, with CGI::Application my $obj = $self->get_obj($id); #else do foo kinda stuff with $obj }
Which wont work because init might return an object to foo (as $obj) or HTML to my C::A (as the output of get_id). I could check the return value of init and act accordingly but I'd rather not. So the question is how do I get the return $self->get_id() in init to return to C::A and not just bounce back to foo?sub foo { my $self = shift; my $obj = $self->init; #do foo kinda stuff with $obj } sub init { my $self = shift; $self->query->param('id'); if (!$id) {return $self->get_id();} my $obj = $self->get_obj($id); return($obj); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: controlling what is returned, where.
by Joost (Canon) on Jul 19, 2005 at 18:13 UTC |