In fact the boilerplate you describe is mostly redundant if you use perl -p since perl -p results in your program running with this wrapper:
LINE:
while (<>) {
... # your program goes here
} continue {
print or die "-p destination: $!\n";
}