#!/usr/bin/perl -T use strict; use warnings; if ( ... a password was not provided ... ) { ... return HTML login form form ... exit; } if ( ... password is not ok ... ) { ... return HTTP error + HTML error message and login form ... exit; } $file_name = ...; if ( ... insufficient permissions... ) { ... return HTTP error + HTML error message ... exit; } if (!open(my $fh, '<', $file_name)) { ... return HTTP error and/or HTML error message ... exit; } print("Content-Type: application/octect-stream\n"); print("\n"); binmode(STDOUT); binmode($fh); $/ = \1024; # Read in blocks of 1024 bytes; print while <$fh>;