"Is there a way to get the "foreach" loop to go to the next array element from within the subroutine?"
Whether this is possible is irrelevant, as this is a bad idea any way. It is a bad idea as it breaks the modulization.
In your demo code, that next is useless any way.
By the way, your routine never took the parameter passed in.
Just to tame your curiosity, try this for once, but never use it in your real code:
use strict;
use warnings;
my @array = (9 .. 11);
foreach my $row (@array) {
&routine($row);
}
sub routine {
my $row = shift;
if ($row != 10) {
print "stuff";
} else {
last;
}
}
This prints only one "stuff", so that that last actually ended the foreach loop.
|