for (@ary) { s/foo/bar/ }
- foreach my $elem (@elements) {
+ for my $elem (@elements) {
$elem *= 2;
}
Whereas here's how a Perl programmer more comfortable with the idiom might
do it:
- OUTER: foreach my $wid (@ary1) {
- INNER: foreach my $jet (@ary2) {
+ OUTER: for my $wid (@ary1) {
+ INNER: for my $jet (@ary2) {
next OUTER if $wid > $jet;
$wid += $jet;
}
dynamically. This allows for computed C<goto>s per FORTRAN, but isn't
necessarily recommended if you're optimizing for maintainability:
- goto ("FOO", "BAR", "GLARCH")[$i];
+ goto(("FOO", "BAR", "GLARCH")[$i]);
The C<goto>-&NAME form is highly magical, and substitutes a call to the
named subroutine for the currently running subroutine. This is used by