[EMAIL PROTECTED] wrote on 08/03/2005 08:16:53 AM:
> I have a subroutine which is supposed to return a reference to an
> array. All this subroutine does is call another sub (i.e.: it's a
> wrapper), which returns the array that the first sub then has to
> return the reference to. Isn't there a one-liner way of doing this?
> I was using:
>
> sub outer_sub {
> @ret_ary = _inner_sub();
> return( [EMAIL PROTECTED] );
> }
>
> where the returned value from _inner_sub is an array:
>
> sub _inner_sub {
> # create @inner_ret_ary. . .
> return( @inner_ret_ary );
> }
>
> which worked fine. But, when I tried to streamline
> outer_sub like this:
>
> return( \_inner_sub()); # _inner_sub just returns @
>
> with the same return value (an array) from _inner_sub, it fails.
Like others have pointed out, you are returning a code reference. Try this
instead:
sub _outer_sub {
return( [ _inner_sub() ] );
}
This creates an anonymous array reference and populates it with the return
from _inner_sub.
Bowie
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs