Documentation for sub
exit assembled from the following types:
sub exit(Int() = 0)
Exits the current process with return code
$status or zero if no value has been specified. The exit value (
$status), when different from zero, has to be opportunely evaluated from the process that catches it (e.g., a shell).
exit does prevent the LEAVE phaser to be executed.
exit should be used as last resort only to signal the parent process about an exit code different from zero, and should not be used to terminate exceptionally a method or a sub: use exceptions instead.
It is worth noting that the only way to return an exit code different from zero from a Main function is by means of using