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: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to