You can put whatever code you want between various when blocks. You can also have more than one default - a default is just a when with a condition that's always true:
my @test = qw [abc def ghi xyz jkl mno]; for (@test) { say "Testing '$_'"; when (/abc/) {say " Got 'abc'"; continue} say " After when /abc/"; when (/def/) {say " Got 'def'"; next;} say " After when /def/"; when (/ghi/) {say " Got 'ghi'";} say " After when /ghi/"; when (/jkl/) {say " Got 'jkl'"; last;} say " After when /jkl/"; default {say " Default 1"; continue} say " After first default"; default {say " Default 2";} say " After second default" } continue { say " Continue for '$_'"; } __END__ Testing 'abc' Got 'abc' After when /abc/ After when /def/ After when /ghi/ After when /jkl/ Default 1 After first default Default 2 Continue for 'abc' Testing 'def' After when /abc/ Got 'def' Continue for 'def' Testing 'ghi' After when /abc/ After when /def/ Got 'ghi' Continue for 'ghi' Testing 'xyz' After when /abc/ After when /def/ After when /ghi/ After when /jkl/ Default 1 After first default Default 2 Continue for 'xyz' Testing 'jkl' After when /abc/ After when /def/ After when /ghi/ Got 'jkl'

In reply to Re^7: Understanding the benefit of Given/When ... by JavaFan
in thread Understanding the benefit of Given/When ... by LanX

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.