(question)
Question:
Answer:
Question:
#!/usr/bin/perl
foreach $x (1,2,3,4,5) {
print "x: $x\n";
if ($x > 2) { print "break\n"; break; }
}
The program prints:
Thex: 1 x: 2 x: 3 break x: 4 break x: 5 break
break
operator does not do the same thing as in C or Python.
Use last
instead. Similarly, use next
instead of
continue
.