#!/usr/bin/perl use strict; use warnings; exit !main(@ARGV); sub main { my $fname = shift; # etc... foo() or return; # Will lead to a non-zero (i.e. unsuccessful) exit-code return 1; # All went well (will lead to a successful exit code of 0) } sub foo { }