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

Re: given/when one case prefixes another

by LanX (Cardinal)
on Apr 26, 2011 at 22:07 UTC ( #901430=note: print w/replies, xml ) Need Help??

in reply to given/when one case prefixes another

without goto and given/when

Bare blocks are internally one-time while-loops allowing continue-blocks (see perlsyn)

for ("a".."c"){ { print && next if /a/; print && next if /b/; # here neither a nor b last; # skip continue-block } continue { # here either a or b print " is in group1"; } print "\n" # all }

your free to have more blocks or combining with elseifs or LABEL:s.

Cheers Rolf


or without fall-through

for ("a".."c"){ { if ( /a/ ) { print } elsif ( /b/ ) { print } else { last } print " is in group"; # a,b } print "\n" # all }

See also: Re^3: given/when one case prefixes another

Replies are listed 'Best First'.
Re^2: given/when one case prefixes another
by John M. Dlugosz (Monsignor) on Apr 27, 2011 at 11:26 UTC
    I see: there are advantages to using if statements instead of when's. I'll keep that in mind.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2020-12-05 03:15 GMT
Find Nodes?
    Voting Booth?
    How often do you use taint mode?

    Results (63 votes). Check out past polls.