in reply to Globalize Filehandles and Visibility in Packages?

Use select

In your module

package Whatever; sub whatever { my $filehandle = select; print $filehandle ...; }

In your program

use Whatever; open my($fh)...; select $fh; whatever('whatever');

Replies are listed 'Best First'.
Re^2: Globalize Filehandles and Visibility in Packages? (dont)
by smknjoe (Beadle) on Mar 07, 2015 at 04:25 UTC

    Thanks anonymous. I didn't know about the select command. I know my method it isn't the preferred method or way to write good code, but the code is only for myself and no one else. Another suggestion I was given at work was to concatenate my strings together until I was complete. Then open the file and dump it all at once and immediately close the file. I just didn't want to drag around an ever-increasing string from one subroutine to another.