【发布时间】:2017-09-06 12:07:39
【问题描述】:
给定一个代码
use Switch;
my $var1x = "one";
switch ($var1x) {
case "one" { print "Why so small?\n"}
case "two" { print "Why so small?\n"}
case "three" { print "That is ok.\n"}
case "four" { print "That is ok.\n"}
}
我想分组执行类似的案例。任何建议如何正确地用 Perl 编写它?
【问题讨论】:
-
case qr/^one|two\z/或case [qw(one two)]=> metacpan.org/pod/Switch#SYNOPSIS
标签: string perl switch-statement