【发布时间】:2010-06-05 08:52:06
【问题描述】:
我可以在 Perl 中执行以下操作吗?
foreach (@tokens) {
if (/foo/){
# simple case, I can act on the current token alone
# do something
next;
}
if (/bar/) {
# now I need the next token, too
# I want to read/consume it, advancing the iterator, so that
# the next loop iteration will not also see it
my $nextToken = .....
# do something
next;
}
}
更新:我在 Perl 中需要这个,但出于好奇:其他语言是否有简洁的语法?
【问题讨论】: