Lines Matching defs:switch

15 # CATCH ATTEMPTS TO CALL case OUTSIDE THE SCOPE OF ANY switch
17 $::_S_W_I_T_C_H = sub { croak "case/when statement not in switch/given block" };
89 return $source unless $Perl5 && $source =~ /case|switch/
118 if ($Perl5 && $source =~ m/\G(\n*)(\s*)(switch)\b(?=\s*[(])/gc
141 $code =~ s/{/{ local \$::_S_W_I_T_C_H; Switch::switch $arg;/;
257 sub switch(;$)
367 croak "Cannot switch on $s_ref";
501 Switch - A switch statement for Perl
512 switch ($val) {
534 between the switch value and the various case values need not be
540 Table 1: Matching a switch value ($s) with a case value ($c)
601 the numerous possible combinations of switch and case values described above.
604 statements: C<switch> and C<case>. The C<switch> statement takes a
606 C<switch> stores this value as the
607 current switch value in a (localized) control variable.
610 The block is unconditionally executed once the switch value has
616 current switch value. The type of matching used is determined by the
617 respective types of the switch value and the C<case> argument, as
626 transferred to the statement after the immediately enclosing C<switch>
641 switch ($_) {
649 switch (sub{ $_[0] < $age } ) {
660 Note that C<switch>es can be nested within C<case> (or any other) blocks,
663 etc. -- against the same switch value.
670 switch ($_[0]) { case 0 { return 'zero' }
681 is usually a Bad Idea in a switch statement. However, this
687 C<switch> block.
691 switch ($val) {
699 If $val held the number C<1>, the above C<switch> block would call the
703 C<switch> block.
711 switch ($val) {
717 immediately transfers control out of the enclosing C<switch> block
722 switch ($val) {
738 switch ($val) {
753 Perl 6 will provide a built-in switch statement with essentially the
755 pair of keywords. In Perl 6 C<switch> will be spelled C<given>, and
757 will not require switch or case values to be parenthesized.
784 One situation in which C<switch> and C<case> do not provide a good
785 substitute for a cascaded C<if>, is where a switch value needs to
789 switch (shift) {
871 switch statement that crosses the 1 million (or 2 million, etc.)