"be consistent" | |
PerlMonks |
Re^4: Perl tk - How to integrate external scriptsby Eliya (Vicar) |
on Jan 27, 2012 at 17:46 UTC ( [id://950426]=note: print w/replies, xml ) | Need Help?? |
$mw-> Button (-text =>'Get Statistics', -command =>\&get_statistics($current_file)); The \&get_statistics($current_file) wouldn't work, as it would call the function right away (with an empty $current_file) at the time the button is set up, and set a reference to its return value as the button callback... In other words, \&func is quite different from \&func(), with the former being a coderef to the function. What you more likely want is
which would call the function with the current value of $current_file at the time the button is pressed. Though, as the variable is global anyway, there's no real need to pass it, so you could also leave it at
and access $current_file directly in the routine. The OP's problem is primarily having made $open (i.e. the name of the selected file) scoped locally to the sub open_file, so it's not available outside of the routine.
In Section
Seekers of Perl Wisdom
|
|