in reply to Re: my $var; vs. use constant VAR = '';
in thread my $var = ''; vs. use constant VAR => '';
Actually constants are faster, since use constant simply turns them into constant subs (for versions of Perl that support this):
IIRC, this form is optimized by the Perl compiler such that there are no hits to the symbol table in dereferencing the value; it would be as if you typed the constant value in as a literal, much like a preprocessor #DEFINE macro.sub CONST_NAME () { 'value' }
update: Looks like I was wrong, my variables are actually a hair faster than both constants and even literal values.
MeowChow s aamecha.s a..a\u$&owag.print
|
---|
In Section
Seekers of Perl Wisdom