http://qs321.pair.com?node_id=11145386


in reply to Re^2: Filehandle in subroutine in use VRML.pm
in thread Filehandle in subroutine in use VRML.pm

... despite my various solutions and workarounds from my nodes here and here being much better than the following, if you're hell-bent on only modifying sub printout, here's enough rope to shoot yourself in the foot: (Update: Note the following only works because of the absence of strict...)

sub printout { my ($lines, $_fh) = @_; my $fh = $_fh ? caller.'::'.$_fh : *STDOUT; foreach my $line (@{$lines}) { print $fh "$line\n"; } } # End printout;

Though you may need to replace caller with the string "main" if printout gets called from another package. /shudder