The Perl interpreter actually returns exit codes if the script does not run. Most syntax errors result in code 9 output:
Unknown function / forbidden word:
perl -e 'use strict; print scalar(localtime); schei;'
$? = 9
division by zero:
perl -e 'use strict; print scalar(localtime); my $s = 1/0;'
$? = 9
Syntax error:
perl -e 'use strict; print scalar(localtime); my $ff; $ff(5;'
$? = 9
using die:
perl -e 'use strict; print scalar(localtime); die "twaeng!"'
$? = 9
the unknown module was the only situation in which I found perl to exit in a different way:
perl -e 'use strict; use doof; print scalar(localtime);'
$? = 2
BTW I'm still looking for a complete list of perl interpreter exit codes. Has anyone got an idea of where to look besides the sources of the perl interpreter?
source share