in reply to "next" in Parallel::ForkManager, and subroutines
You use next to jump out of a sub. That's fine. It's supported.
Minimal example:
use 5.010; use strict; sub my_sub { next }; for (1..5) { say "Hello"; my_sub(); say "World"; }
This says "Hello" five times, but does not say "World" because the sub my_sub calls next.
While it's supported by Perl, it's also considered a slightly odd thing to do - and quite non-obvious (the sub my_sub could be defined hundreds of lines away from the loop which uses it, or even in another file), so Perl warns you about it, just in case you're doing it accidentally. If you run my example with warnings switched on, you'll get five warnings about exiting the sub using next, but these are just warnings, not errors. The script prints out a warning, but keeps on running.
If you're doing it deliberately, and don't want to be warned about it then:
no warnings qw[exiting];
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: "next" in Parallel::ForkManager, and subroutines
by thargas (Deacon) on Apr 04, 2012 at 18:56 UTC | |
by tobyink (Canon) on Apr 23, 2012 at 10:07 UTC |