$ perl -e " return " Can't return outside a subroutine at -e line 1. $ perl -Mdiagnostics -e " return " Can't return outside a subroutine at -e line 1 (#1) (F) The return statement was executed in mainline code, that is, where there was no subroutine call to return out of. See perlsub. Uncaught exception from user code: Can't return outside a subroutine at -e line 1. at -e line 1.