athanasia has asked for the wisdom of the Perl Monks concerning the following question:
I have the following issue. I must build a wrapper subroutine around an existing subroutine. The "inner" subroutine whose code I cannot fiddle with may return different things, i.e. sometimes it returns a hash, sometimes a scalar and sometimes a list. After doing some other tasks, the wrapper must return the return value of the inner function. How do you suggest I handle this?
sub __func__ { #handle @arglist if () { return %myhash; } else if () { return $myscalar; } else { return @mylist; } } sub func() { #some input &__func__(@arglist); #how can i handle different return values of __func__? #some other stuff }
Thanks in advance,
Athanasia
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Grab return values of different type from a sub
by BrowserUk (Patriarch) on Jul 29, 2010 at 12:34 UTC | |
|
Re: Grab return values of different type from a sub
by Sue D. Nymme (Monk) on Jul 29, 2010 at 12:49 UTC | |
|
Re: Grab return values of different type from a sub
by Utilitarian (Vicar) on Jul 29, 2010 at 11:14 UTC |