Pass file handle reference to a subroutine
sub printem { my $file = shift; while (<$file>) { print; } } open FILEHANDLE, "<file.txt" or die "Can not open file"; printem *FILEHANDLE;