In order to call them from menubuttons I moved my code into subroutines.
sub open_file {
if ( ! open NEWFILE, "<$file") {
die "Could Not Open $file: $!"
} else {
my @lines = <NEWFILE>;
$message = "Open File" . $file;
}
} # End sub open_file
sub edit_file {
$lbox -> insert ('end', @lines);
...
The array @lines was declared as
use Tk;
use strict;
my @lines = ();
at the top of the program and $lbox is a Listbox. The code worked
perfectly in the main program but when moved into subroutines the array
@lines is an empty array when the second subroutine is called.
How should this be coded?
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/