This isn't likely to go anywhere. Here's why:

Unless a prototype disallows it, it's always legal to pass an in-scope lexical scalar variable to a subroutine call. Perl doesn't really care at compiletime what the subroutine actually does with parameters passed into it. So the only safeguard Perl can reasonably do is complain if you make some system call that requires a filehandle, and pass in a closed one. That's a runtime check though, because the compiler doesn't grok the logic enough to know that a given variable is in some particular state.

But Perl already does complain when you attempt to do some file operation on a closed filehandle -- that already generates a warning. In your case, the situation comes up infrequently, so the warning is latent, and not likely to appear right away. But I do think Perl is doing the best it can in that regard already. At what line in the code you posted should Perl kknow you're doing something nutty?

my_sub($first_fh,...

...that's not a reasonable place, because Perl doesn't really know the purpose of my_sub, and doesn't know at this point what you are planning to do with $first_fh.


Dave


In reply to Re: Propose addition to use warnings? by davido
in thread Propose addition to use warnings? by perldigious

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.