in reply to Re^8: Modernizing the Postmodern Language?
in thread Modernizing the Postmodern Language?

You are correct about needing the :lvalue attribute, but if I understand correctly, my will create a new scalar every time FH is called.

Another alternative could be: { my $fh; sub FH :lvalue { $fh } }, using the closure to capture a single instance of the lexical. TIMTOWTDI really works!

Replies are listed 'Best First'.
Re^10: Modernizing the Postmodern Language?
by LanX (Saint) on Jul 06, 2020 at 01:11 UTC
    you are right of course, a closure was my initial idea, dunno why I lost it here.

    FWIW state might be an alternative

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery