programming-examples/perl/Subroutine/Pass file handle global reference to a subroutine.pl

8 lines
162 B
Perl
Raw Normal View History

2019-11-15 12:59:38 +01:00
sub printhello
{
my $handle = shift;
print $handle "Hello!\n";
}
open FILEHANDLE, ">file.tmp" or die "Can't open file.";
printhello(\*FILEHANDLE);