Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Re: my $var; vs. use constant VAR = '';

by MeowChow (Vicar)
on Apr 27, 2001 at 01:12 UTC ( #75917=note: print w/ replies, xml ) Need Help??


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):

sub CONST_NAME () { 'value' }
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.

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


Comment on Re: Re: my $var; vs. use constant VAR = '';
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://75917]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (13)
As of 2014-08-22 16:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (160 votes), past polls