A quote from perldiag:
Statement unlikely to be reached
(W exec) You did an exec() with some statement after it other than a
die(). This is almost always an error, because exec() never returns
unless there was a failure. You probably wanted to use system()
instead, which does return. To suppress this warning, put the exec()
in a block by itself.
In practice:
$ perl -Mwarnings -C -E 'exec "true"; say "Hello."'
Statement unlikely to be reached at -e line 1.
(Maybe you meant system() when you said exec()?)
Is there some reason, other than "not implemented yet", that we don't have a similar warning for "exit"?
(This came up because a coworker wrote "exit $OK ? 0 : 1", which I know that even this wouldn't catch.)
--
rjbs
Statement unlikely to be reached
(W exec) You did an exec() with some statement after it other than a
die(). This is almost always an error, because exec() never returns
unless there was a failure. You probably wanted to use system()
instead, which does return. To suppress this warning, put the exec()
in a block by itself.
In practice:
$ perl -Mwarnings -C -E 'exec "true"; say "Hello."'
Statement unlikely to be reached at -e line 1.
(Maybe you meant system() when you said exec()?)
Is there some reason, other than "not implemented yet", that we don't have a similar warning for "exit"?
(This came up because a coworker wrote "exit $OK ? 0 : 1", which I know that even this wouldn't catch.)
--
rjbs