use utf8; use 5.022; use strict; say "BEGIN"; open(my $out_fh, ">", "permission_denied_output_file.txt") or die "Cannot open \"permission_denied_output_file.txt\": $!."; open(my $in_fh, "<", "no_such_input_file.txt") or die "Cannot open \"no_such_input_file.txt\": $!."; say "END"; END { use ExtUtils::MakeMaker qw(prompt); # placing this use statement here for convenient copy-paste of this END block code to other scripts. prompt('Please hit enter to exit.') if ($?); # stop and prompt for acknowledgement if program exits with a non-zero value. }