Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
Re: Filehandle in subroutine in use VRML.pmby haukex (Archbishop) |
on Jul 06, 2022 at 21:03 UTC ( [id://11145313]=note: print w/replies, xml ) | Need Help?? |
Thank you for providing enough code to reproduce your issue! The problem is that because you're not using strict "refs" (Update: and strict "subs"), there is some funky symbolic reference stuff going on here. It's unclear to me why you even need to pass the parameter LF in &mystart($LumberFile,LF);, but AFAICT what is going on here is that that call is actually being interpreted as &mystart($LumberFile,"LF");, and then inside VRML.pm there is no filehandle named LF because that was opened in the main package. The best thing to do is to rewrite your code so that it works under strict and warnings. The minimum changes I would recommend is to change the definition and call of mystart as follows:
If you need the $fh parameter to mystart, you need to show us more context as to how it gets used for us to make a recommendation for a useful replacement (Update: Re^3: Filehandle in subroutine in use VRML.pm). However, I see several other older code styles in your sample code, for example using the -w shebang switch (What's wrong with -w and $^W), using the old ampersand-style sub calls (perlsub), and the two-argument open ("open" Best Practices). So here's your sample code updated to modern Perl, I strongly suggest you adopt this style for all your code:
VRML.pm:
Warning:
In Section
Seekers of Perl Wisdom
|
|