First of all, use strict; will help you to find some variable declaration errors !

The big problem is, that you wrote TopLevel instead of Toplevel
This is a quick shoot for your script:

use strict; use warnings; use Tk; my $listbox; my $mw=MainWindow->new; $mw->geometry('800x600'); my $menu_bar = $mw->Frame(); my $rf = $mw->Frame; my $search_mb = $menu_bar->Menubutton('-text' => 'File', '-relief' => 'raised', '-borderwidth' => 2, )->pack('-side' => 'left', '-padx' => 2 ); $search_mb->command('-label' => 'Open', '-accelerator' => 'Ctrl+o', '-underline' => 0, '-command' => \&open_file ); $search_mb->command('-label' => 'Save', '-accelerator' => 'Ctrl+s', '-underline' => 0, '-command' => \&save_file ); $search_mb->command('-label' => 'Close', '-accelerator' => 'Ctrl+x', '-underline' => 0, '-command' => \&close_file ); $search_mb->command('-label' => 'Exit', '-accelerator' => 'Ctrl+q', '-underline' => 0, '-command' => [$mw => 'destroy'] ); my($InputText) = $rf->Scrolled('TextUndo', -height => '1', -width => '1', -scrollbars => 'osoe', ); $menu_bar->pack(-anchor => 'nw'); $rf->pack(qw/-side right -fill both -expand 1/); $InputText->pack(qw/-side top -fill both -expand 1/); MainLoop; sub open_file{ my $open = $mw->Toplevel; $open->geometry('400x550'); my $tf = $open->Frame; my $bf = $open->Frame; $listbox = $tf->Listbox(-height => '10', -selectmode => 'browse', -width => '40', -relief => 'sunken', -setgrid => '1'); $listbox->delete('0.1', 'end'); opendir DIR, "."; $listbox->insert('end', grep { -f $_ && -r $_ } readdir DIR); close DIR; my $button = $bf->Button( -command => \&load, -text => 'Open'); $tf->pack; $bf->pack; $button->pack(-anchor => 'se'); } sub load{ my ($index) = $listbox->curselection(); my $filename = $listbox->get($index); $InputText->Load( $filename ); (my $script = $0) =~ s,.*(\/|\\),,; }
As you can see, you just have to use Tk and all the other required modules need not to be used here.

Hope this helps.

-----------------------------------
--the good, the bad and the physi--
-----------------------------------

In reply to Re: How can you redefine a subroutine?? by physi
in thread How can you redefine a subroutine?? by eoin

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.