WARNING - THIS SUGGESTION IS FRAUGHT WITH PERIL
Use this at your own risk. I am not responsible if you get fired.

You could unroll the function call stack (using goto and dynamic labels) and manipulate it yourself. This is ... very poor form, requires a book of comments, and is about as fragile as bone china. But, it is possible.

Let's say you have:

my $value = foo( 3, 4, 5 ); for ( 1 .. 10_000 ) { # Blahblah my $inside_value = foo( $_, 1, 2 ); # Yadda, yadda, yadda } my $other_value = foo( 7, 8, 9 ); sub foo { my ($first, @args) = @_; do_something( $first ); return do_something_else( @args ); }
That looks to be roughly what you're doing, right? Well, you can transform that code as so:
my $LABEL; my @FOO_ARGS; my $FOO_RV; $LABEL = 'FIRST'; @FOO_ARGS = ( 3, 4, 5 ); goto FOO; FIRST: my $value = $FOO_RV; $LABEL = undef; $FOO_RV = undef; for ( 1 .. 10_000 ) { # Blahblah @FOO_ARGS = ( $_, 1, 2 ); FOO: { my ($first, @args) = @FOO_ARGS; do_something( $first ); $FOO_RV = do_something_else( @args ); goto $LABEL if $LABEL; } my $inside_value = $FOO_RV; # Yadda, yadda, yadda } $LABEL = 'SECOND'; @FOO_ARGS = ( 7, 8, 9 ); goto FOO; SECOND: my $other_value = $FOO_RV; $LABEL = undef; $FOO_RV = undef;

Note: I am not advocating this type of code nor am I suggesting that you won't be hunted down like the fool you are if you implement this code and quit the next day. I'm saying that you can inline functions in Perl that are called from outside the loop and here is how.

Being right, does not endow the right to be rude; politeness costs nothing.
Being unknowing, is not the same as being stupid.
Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.


In reply to Re: Inline - Subroutine Overhead by dragonchild
in thread Inline - Subroutine Overhead by santhosh

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.