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!