Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^2: Calling subrutine with \& and passing variables

by IB2017 (Pilgrim)
on Oct 29, 2017 at 01:56 UTC ( [id://1202252]=note: print w/replies, xml ) Need Help??


in reply to Re: Calling subrutine with \& and passing variables
in thread Calling subrutine with \& and passing variables

Thank you for your reply. What I want to achive is actually quite simple: I'd like to pass the variable $SomeVariable to my subrutine to further process it (the code is a simplified version of my real code which is a quite complex GUI with many dynamically generated variables I need to process once the user has "dropped" a file into the widget).

Hardcoding the variable in the subrutine doesn't seem to me viable as the variable is generated outside of it. Using a closure variable - as far as I understand - implies an "answer" from the subrutine (but I may be wrong about what a closure variable is). Inspecting the tk data structures hasn't helped me, unfortunately.

  • Comment on Re^2: Calling subrutine with \& and passing variables

Replies are listed 'Best First'.
Re^3: Calling subroutine with \& and passing variables
by LanX (Saint) on Oct 29, 2017 at 07:49 UTC
    Just use $SomeVariable inside your subroutine.

    Because it's declared outside with my it becomes a "closure variable".

    Cheers Rolf
    (addicted to the Perl Programming Language and ☆☆☆☆ :)
    Je suis Charlie!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (6)
As of 2024-04-23 13:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found