in reply to Re^2: lexical vs. local file handles
in thread lexical vs. local file handles

It's probably possible to make localized bareword filehandles work, if you take a whole lot of care to avoid all the issues. But then again, you could be spending all that care on avoiding print $fh, "", couldn't you? (You could probably even write a Perl::Critic policy to avoid it - Perl::Critic::Policy::InputOutput::ProhibitBarewordFileHandles already exists.) I guess I should have worded my point above as a question:

Other than catching the print FH, "" issue, what advantages to using bareword filehandles do you see over lexical filehandles?

Edit: Added link to module.

Replies are listed 'Best First'.
Re^4: lexical vs. local file handles
by jo37 (Curate) on Apr 18, 2020 at 19:52 UTC

    My point is: bareword filehandles are something special in Perl syntactically. Avoiding them cuts off a part of the language.

    Greetings,
    -jo

    $gryYup$d0ylprbpriprrYpkJl2xyl~rzg??P~5lp2hyl0p$

      You could say the same thing about goto and mutable global variables and even $[ (which, fortunately, is gone in newer language releases), but in general the same reason to avoid them applies: because using them makes it more difficult to reason about code in the small and the large.


      Improve your skills with Modern Perl: the free book.

      My point is: bareword filehandles are something special in Perl syntactically. Avoiding them cuts off a part of the language.

      Ok, but that wasn't my question...

        TIMTOWTDI. My question is: "Why not?".

        Greetings,
        -jo

        $gryYup$d0ylprbpriprrYpkJl2xyl~rzg??P~5lp2hyl0p$