Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re^3: Pearls (not really) of Perl programming

by bart (Canon)
on Nov 25, 2004 at 11:57 UTC ( #410372=note: print w/replies, xml ) Need Help??

in reply to Re^2: Pearls (not really) of Perl programming
in thread Pearls (not really) of Perl programming

It's not that bad, at least in perl, as it appears to optimize it away. At least, on ActivePerl 5.8.4, the following script:
#! perl $x = 3; if(0 || $x == 2 || $x == 3) { print "Yeah!\n"; }
under `perl -MO=Deparse`, produces: syntax OK $x = 3; if ($x == 2 or $x == 3) { print "Yeah!\n"; }

In general, I prefer my "||" on the right:

$x = 3; if( $x == 2 || $x == 3) { print "Yeah!\n"; }

If you want, you can still append "|| 0" to the condition, allowing for more symmetry, but not optimized away. At least it'll only be executed if every other condition fails.

There's a reason why Perl accepts lists ending with ",", or at least: it's a good thing Perl accepts lists ending with ",". In a way it's too bad (tough understandable) it won't do the same for "||".

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://410372]
[choroba]: Morning!
[Corion]: Hi choroba, Discipulus!
[Corion]: Yesterday I've been mulling over how to best generate HTTP requests from permutations of values but I haven't found a nice API for passing in the "template" of the HTTP request yet. I guess I'll have to do a SoPW for that
[Corion]: The API itself will basically be my $iter = generate_http_requ ests(method => 'GET', url => '/settings/:name', headers => ???, get_params => ['foo','bar']), but I'm not sure how to parametrize values in the headers and how to specify lists of ...
[choroba]: On the other hand, lots of options to receive the requests :-)
[Corion]: ... values to be used. For example, I think for headers, one would want to have various kinds of Content-Encoding headers, but for the get_parameters one would have various kinds of Bobby Tables

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2017-01-17 08:10 GMT
Find Nodes?
    Voting Booth?
    Do you watch meteor showers?

    Results (152 votes). Check out past polls.