in reply to how to write a subroutine content into a file

sub doit{ return "How are you?\n"; } open (FILE, ">files.txt"); print FILE &doit; close(FILE);
Or
sub doit{ my $handle = shift; print $handle "How are you?\n"; } open (FILE, ">files.txt"); doit(*FILE); close(FILE);
Or .. lots of ways.