Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Re: Re: Re: Re: Re: Perl Idioms Explained: && and || "Short Circuit" operators

by BrowserUk (Pope)
on Oct 23, 2003 at 19:46 UTC ( #301689=note: print w/replies, xml ) Need Help??

in reply to Re: Re: Re: Re: Perl Idioms Explained: && and || "Short Circuit" operators
in thread Perl Idioms Explained - && and || "Short Circuit" operators

I look forward to the power of the P6 Given/When construct immensely, but I still hanker for the the limited but oh-so-useful and efficient switch/case construct. There are so many occasions when this simple integer-based dispatch mechanism is exactly all that is needed, that I think it would be worth having, in addition to the much more powerful, but equally, much less efficient Given/When construct.

I'm aware of theDamian's switch module, but it attempts to be much more than a simple switch construct, coming much closer to the given/when flexibility. The downside of that it that it is much less efficient for the predominant 'simple case'. I've also had problems with it getting confused.

Hash based dispatch tables are okay and pretty efficient, but the need to put the selected code into either a sub or runtime eval makes it less useful for things where the selected code is minimal and speed important. Calling a sub to increment or decrement a count is high overhead if your scanning long strings and maintaining counts as you go.

Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"Think for yourself!" - Abigail

  • Comment on Re: Re: Re: Re: Re: Perl Idioms Explained: && and || "Short Circuit" operators

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://301689]
[amitkumarj441]: I need to ask a question, where can I post my problem?
[Discipulus]: everyone is me
[Discipulus]: Seekers of Perl Wisdom is the for asking question
[Discipulus]: be sure to use code tags for code and data
[Discipulus]: and to show some effort while asking
[Discipulus]: <code> code and data</code>
[Discipulus]: amitkumarj441 more atention you put asking, more attentio you got in answers
Discipulus 's hoping he needs a oneliner ;=)

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2017-04-26 20:23 GMT
Find Nodes?
    Voting Booth?
    I'm a fool:

    Results (488 votes). Check out past polls.