How do I print to a file from a sub routine when using strict subs?
I have a program that opens a file in the main portion of the code and then calls a sub that needs to print to the same file as well. I would like to avoid opening and closing the file every time I have to write to it.
In Java I would open the file in the main sub and then pass the file as an object to whatever sub nees to print to it.
ie:
public main(){ FileWriter file = new fileWriter(); file.open("file.txt"); print_sub(file); } private print_sub(FileWriter file){ //do something with the file }
is there a way to do this in Perl? thanks in advance
In reply to Printing to a File from Sub by PyrexKidd
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |