foreach my $i (@list1) { foreach my $j (@list2) { if ($i == 5 && $j == 23) { last; } } # this is where that last sends you } The command only terminates the innermost loop. If you want to break out of the last outer loop, you need to use loop labels: OUTER: foreach my $i (@list1) { INNER: foreach my $j (@list2) { if ($i == 5 && $j == 23) { last OUTER; } } } # this is where that last sends you The loop label is a string that appears before the loop command (foreach, for, or while). In this example we used OUTER as the label for the outer foreach loop and INNER for the inner loop label. Now that you've seen the various of Perl control structures, let's look at how to apply them to handling advanced form data. Fundamentals of arrays An stores an ordered list of values. While a scalar variable can only store one value, an array can store many. Perl array names are prefixed with an @-sign. Here is an example: my @colors = Each individual item (or element) of an may be referred to by its index number. Array indices start with 0, so to access the first element of the array @colors, you use $colors[0]. Notice that when you're referring to a single element of an array, you prefix the name with $ instead of @. The $-sign again indicates that it's a single (scalar) value; the @-sign means you're talking about the entire array.
foreach my $i (@list1) { foreach my $j (@list2) { if ($i == 5 && $j == 23) { last; } } # this is where that last sends you } The last command only terminates the innermost loop. If you want to break out of the outer loop, you need to use loop labels: OUTER: foreach my $i (@list1) { INNER: foreach my $j (@list2) { if ($i == 5 && $j == 23) { last OUTER; } } } # this is where that last sends you The loop label is a string that appears before the loop command (foreach, for, or while). In this example we used OUTER as the label for the outer foreach loop and INNER for the inner loop label. Now that you've seen the various of Perl control structures, let's look at how to apply them to handling advanced form data. Fundamentals of arrays An stores an ordered list of values. While a scalar variable can only store one value, an array can store many. Perl array names are prefixed with an @-sign. Here is an example: my @colors = Each individual item (or element) of an may be referred to by its index number. Array indices start with 0, so to access the first element of the array @colors, you use $colors[0]. Notice that when you're referring to a single element of an array, you prefix the name with $ instead of @. The $-sign again indicates that it's a single (scalar) value; the @-sign means you're talking about the entire array.