in reply to Re: Filehandle in subroutine in use VRML.pm
in thread Filehandle in subroutine in use VRML.pm
In the past my vrml scripts have always generated one set of VRML statements written to STDOUT on a given run, but in this latest script I wanted to create two wrl files in DrillPressTable.pl:
my $LumberFile="$Dir/$Subdir/lumber.wrl"; my $DrillPressTableFile="$Dir/$Subdir/$Subdir.wrl"; &mystart($LumberFile,LF); &buildlumber(\%Fs,LF,$Ppi); &mystart($DrillPressTableFile,DP); &buildtable(\%Fs,DP,$Ppi);
The original printout subroutine in VRML.pm looked like this, which I couldn't now use in DrillPressTableFile.pl because it had no provision for directing output to a filehandle other that STDOUT:
<code> sub printout { my($lines)=@_; foreach my $line (@{$lines}) { print "$line\n"; } } # End printout; </code)The suggestion by Mr. Marshall didn't work, because the problem occurs when $fh at entry to printout is defined. Setting $fh to STDOUT is to have a default, and perhaps that would've been a problem if I'd gotten past the original problem of passing a filehandle to printout.
The myprint subroutine was to be only temporary until I figured out how to change printout to accept a filehandle, which brings me to my original question: How do I declare $fh in subroutine printout so it recognizes the intended filehandle?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Filehandle in subroutine in use VRML.pm
by haukex (Archbishop) on Jul 07, 2022 at 20:10 UTC | |
|
Re^3: Filehandle in subroutine in use VRML.pm
by Marshall (Canon) on Jul 11, 2022 at 20:58 UTC | |
by bliako (Abbot) on Jul 12, 2022 at 12:03 UTC |