Ah, but: sub BUFFER() { 2048 } is also a compile-time construct.
The () means that uses of BUFFER can be optimized away so that the code gets compiled as if you said 2048 directly. Without the (), each time an instance of BUFFER is encountered at run time, a Perl subroutine call has to be executed.
I doubt you'd be able to notice a speed difference between the two without trying really hard. But it also makes the compiled code a little smaller and declares your intention to not change this definition at run time.
- tye (but my friends call me "Tye")In reply to (tye)Re: subroutine constants
by tye
in thread subroutine constants
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |