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

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


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

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1004868]
Discipulus a missing semicolon after use LWP::UserAgent caused very strange behaviour and not the normal warning...
[choroba]: Yes, sometimes missing ; after the use clause just interprets the next line somehow and passes the result to the used module which could happily ignore it. Been there, seen that.
[Discipulus]: luckly the program was 20 lines!

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (10)
As of 2017-02-28 08:49 GMT
Find Nodes?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?

    Results (398 votes). Check out past polls.