I'm not a terribly experienced programmer so forgive me if this is not a bug, but this is a bug, right? In the Paste subroutine in TableMatrix.pm:
# Paste -- # This procedure pastes the contents of the clipboard to the specified # cell (active by default) in a table widget. # # Arguments: # w - Name of a table widget. # cell - Cell to start pasting in. sub Paste { my $w = shift; my $cell = shift || ''; ## Perltk not sure if translated correctly my $data; if ($cell ne '') { eval{ $data = $w->GetSelection(); }; return if($@); } else { eval{ $data = $w->GetSelection('CLIPBOARD'); }; return if($@); $cell = 'active'; } $w->PasteHandler($w->index($cell),$data); $w->focus if ($w->cget('-state') eq 'normal'); }
In the eval statements I believe there is a bug. The purpose of the statments appears to be to test whether there is a selection available in the Clipboard (on the Clipboard?) and if there isn't, then to just return. because inside the eval statement if there is no selection available in the Clipboard then GetSelection sets the $@ variable, but the return statements are actually outside of the eval statements and at that point $@ is once again empty. So, shouldn't the return statements be inside of the eval statements? Or am I missing the point of the eval statements?

Oh wait! return wouldn't exit the subroutine if it were inside the eval, it only exits the eval, right? I am confused. What is the point of the eval supposed to be?

OK, so I read the man page on eval again, and it looks like the code should work the way it is. But for some reason, $@ does not stay set after leaving the eval block.

I realize now that if GetSelection() did cause an error, then the eval block should be exited immediately with $@ set to the error, correct? THen the code above would work as intended. But for some reason it seems that if GetSelection creates an error due to there being no selection that even though $@ is set, the eval block is not exited. It just continues executing. So the eval block exits normally and $@ is reset to empty.

would this happen because GetSelection is doing something with $SIG{__DIE__}?


In reply to This is a small bug in TableMatrix.pm, right?? by gleepglop

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.