Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^3: new way to code html?

by Anonymous Monk
on Nov 21, 2012 at 08:23 UTC ( #1004868=note: print w/replies, xml ) Need Help??


in reply to Re^2: new way to code html?
in thread new way to code html?

use of the ternary for simple conditionals is a handy trick to have up your sleeve.

I'd worry about having a grasp of the language (context, syntax) before worrying about micro-optimizations

-MO=Deparse,-p says

use Benchmark (':all'); my($foo, $bar); cmpthese((-1), {'ternary', sub { ((int(rand(2)) ? ($foo = 1) : $bar) = 1); } , 'if_else', sub { if (int(rand(2))) { ($foo = 1); } else { ($bar = 1); } } });

More clearly  ((int(rand(2)) ? ($foo = 1) : $bar) = 1);

is

( ( int(rand(2)) ? ($foo = 1) : $bar ) = 1 );
which is an error

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1004868]
help
Chatterbox?
Discipulus was a question
[GotToBTru]: current job found me
Discipulus is so lucky to have a decent job, with old, favorable contract, done before the ultralibersm arrived in Eataly
[Lady_Aleena]: Has anyone here ever use pcregrep? I can't seem to get the --include regex right. --include=*.p[lm] works in grep but not pcregrep.
[erix]: to lift your spirits, here is some more happy Randy news...
[Lady_Aleena]: The reason I would like to use pcregrep is because it can do multiline searches supposedly.
[perldigious]: What are your criteria for looking Tanktalus? What things must a job have for you to consider it? And where are you in your career? Start, middle, or end?
[erix]: are there any regex-engines that do not do multiline?
[Lady_Aleena]: erix, grep doesn't.
[Lady_Aleena]: Linux grep that is...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (9)
As of 2017-05-23 19:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?