ISAI student has asked for the wisdom of the Perl Monks concerning the following question:
Hello all. I have subroutine sub1 which outputs an array. I cannot alter that subroutine right now. Subroutine sub2, that needs expanding, uses it's output. The expansion requires that I pass a reference to the array/list output of sub1. Right now, I am using it like this:
Iknow that it can be replaced by:sub2( sub1() ) ;
Is there a way of not using 2 lines. instead of one I.E.{ # minimal scope for @temp my @temp = sub1() ; sub2 ( \@temp ) ; } # end of local scope
It's a matter of cooler code, not of true need.sub2( some_code( sub1() ) )
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: on the fly reference to subroutine output
by choroba (Cardinal) on Mar 04, 2013 at 14:51 UTC | |
by tmharish (Friar) on Mar 04, 2013 at 14:54 UTC | |
by ISAI student (Scribe) on Mar 04, 2013 at 15:12 UTC | |
by 7stud (Deacon) on Mar 05, 2013 at 02:45 UTC | |
by tmharish (Friar) on Mar 05, 2013 at 07:54 UTC | |
by thirdm (Sexton) on Mar 04, 2013 at 18:30 UTC | |
by Anonymous Monk on Mar 04, 2013 at 19:45 UTC | |
by thirdm (Sexton) on Mar 05, 2013 at 05:28 UTC |
Back to
Seekers of Perl Wisdom