If you have code that actually runs, you should paste the relevant part of the running code when you post (or at least be more careful about typing/pasting it in). What you have here has some glaring errors. Update as you see fit (and mention what you've updated), but when I first saw this post, there were the following problems:
- The first curly brace is a close-brace, not an open-brace -- it doesn't compile.
- You have "opendir(SPAM...)" followed by "close(SPAM)", not "closedir(SPAM)" -- maybe that actually works, but it just seems wrong.
- Is "%temp" actually a global hash (like $mw appears to be a globally declared "MainWindow" widget)? If not, it isn't being declared with "my" where it should be. Likewise for $new in "sub view". (Does the script "use strict", or not? If not, try it, please.)
- You aren't checking for success or errors when opening files in the "view()" sub -- likewise for opening the directory.
As for the symptom -- the buttons appear to be labeled as intended, but you aren't seeing the file name or its contents in the new Toplevel window when you hit a button -- well, it's hard to comment on this, because you say your code runs, but what you've posted won't run, so you haven't posted the code that produces that symptom.
Anyway, you might try initializing the "-command" parameter on the button like this:
...
-command => [ \&view, $open ],
...
This way, the "-command" option gets a reference to an anonymous array; the first element of the array is a reference to a subroutine to be run when the button is clicked, and subsequent elements in the array (one in this case) are parameters to be passed to the subroutine in @_.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.