Well, what the first couple folks said doesn't actually answer your question... they were answering what *would* have been your question if you *had* had break statements... I don't know if the original post was updated after the fact or if they simply did not actually read it... whatever.
The short answer is that there isn't anything that does this very well, and in the same way as C does. The thing to understand is that switch statements in C are actually just well-written GOTO statements! Likewise, the best way to do this might be GOTOs (as bad as that might sound)... or just coding it explicitly, something like:
for ( $var ) {
my $go;
($go || $_ == 10) and $go++, print "a";
($go || $_ == 9 ) and $go++, print "b";
($go || $_ == 8 ) and $go++, print "c";
($go || $_ == 7 ) and $go++, print "d";
($go || $_ == 6 ) and $go++, print "e";
($go || $_ == 5 ) and $go++, print "f";
($go || $_ == 4 ) and $go++, print "g";
($go || $_ == 3 ) and $go++, print "h";
($go || $_ == 2 ) and $go++, print "i";
($go || $_ == 1 ) and $go++, print "j";
}
------------
:Wq
Not an editor command: Wq
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.