क्या मैं पर्ल में निम्नलिखित की तरह कुछ कर सकता हूं?क्या मैं अगले तत्व को पर्ल फ़ोरैच लूप के भीतर से खींच सकता हूं?
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;
}
}
अद्यतन: मैं पर्ल में इस की जरूरत है, लेकिन जिज्ञासा की खातिर: क्या अन्य भाषाओं के लिए एक साफ वाक्य रचना है?
अच्छा। मेरे मामले में, मूल को नष्ट करना भी एक समस्या नहीं है, इसलिए मैं प्रतिलिपि के बिना कर सकता हूं। – Thilo