Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^9: Modernizing the Postmodern Language?

by jcb (Parson)
on Jul 06, 2020 at 01:03 UTC ( [id://11118948]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11118948]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2024-03-28 17:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found