Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^3: Infinite LOOP and reading from STDIN

by AnomalousMonk (Archbishop)
on Aug 13, 2019 at 20:24 UTC ( [id://11104417]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Infinite LOOP and reading from STDIN
in thread Infinite LOOP and reading from STDIN

Glivter:   Further to haukex's reply:   In certain cases, I find  ? : ternary chains (update: I've also seen them referred to as "ladders") very neat, clear, readable and maintainable, and useful:

my $result = CONDITION1 ? EXPRESSION1 : # "if" case CONDITION2 ? EXPRESSION2 : # "elsif" case CONDITION3 ? EXPRESSION3 : # ditto ... # and so on... die "no condition met... " # "else" default case ;
And, of course, you don't have to die or take any other drastic action in the default case, but simply return a default value. Your EXPRESSION can also be a side-effect-possessing  do { ... } expression or subroutine call that returns a meaningful value. (A do-block or subroutine call always returns a value, but if you don't design it right, that value may be surprising.)


Give a man a fish:  <%-{-{-{-<

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11104417]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2024-03-28 20:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found