主要是因为perl是自然语言, given/when 多么的自然, 像英语一样 ,
2011/7/18 joe jiang <[email protected]> > 另外,given 和 for 都可以匹配 when,相比之下,使用 case 来搭配 for 循环,可能更容易引起 C > 程序员的困惑。还是新发明一种语法更加好些。下面是 perlsyn 的例子: > > given ($something) { > $abc = 1 when /^abc/; > $just_a = 1 when /^a/; > $other = 1; > } > > for (@names) { > admin($_) when [ qw/Alice Bob/ ]; > regular($_) when [ qw/Chris David Ellen/ ]; > > } > > -- > 您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。 > 要向此网上论坛发帖,请发送电子邮件至 [email protected]。 > 要取消订阅此网上论坛,请发送电子邮件至 [email protected]。 > 若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。 > -- Yours Sincerely Zeng Hong -- 您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。 要向此网上论坛发帖,请发送电子邮件至 [email protected]。 要取消订阅此网上论坛,请发送电子邮件至 [email protected]。 若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。
