$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
$mw-> Button (-text =>'Get Statistics', -command => sub { get_statisti +cs($current_file) } );
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
-command => \&get_statistics
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 reply to Re^4: Perl tk - How to integrate external scripts
by Eliya
in thread Perl tk - How to integrate external scripts
by Giorgio C
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |