Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^3: var comparison

by Marshall (Prior)
on Sep 09, 2012 at 19:14 UTC ( #992617=note: print w/ replies, xml ) Need Help??


in reply to Re^2: var comparison
in thread var comparison

I think that $var eq 'foo' || $var eq 'bar' will work very well. If $var is say 'xyz', the string compare will be abandoned at the first letter. "Oh, its not an 'f', lets see if the first letter is an 'b' ... The regex engine is amazing but an expression like this will just call a low level 'C' function that is very efficient.

My point is that "shorter" source code is not necessary "better" in terms of efficiency or readability.


Comment on Re^3: var comparison
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://992617]
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: (16)
As of 2014-08-22 14:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (158 votes), past polls