in reply to Re^3: sprintf vs. substr (for zero-padded values)
in thread sprintf vs. substr (for zero-padded values)

Wow... ++tadman for discovering the flaw in my master plan, and for opening my eyes to how expensive calling a subroutine seems to be. Why is calling a sub so expensive?
  • Comment on Re: Re^3: sprintf vs. substr (for zero-padded values)

Replies are listed 'Best First'.
Re: sprintf vs. substr (for zero-padded values)
by Abigail-II (Bishop) on Jul 18, 2002 at 13:38 UTC
    Why is calling a sub so expensive?
    You got to save state (and restore it when the sub returns). Furthermore, the lookup is done at runtime, not compiletime. After all, it's fine to have a call to a sub preceed the actual declaration - not to mention that AUTOLOAD would work if all was done at compile time.

    Abigail