in reply to suppress Perl Tk:error

Read "perldoc Tk::Error". You can either "require Tk::ErrorDialog" to redirect the error from stdout to a popup; OR you can define the sub Tk::Error to do what you want. Just return from sub Tk::Error to suppress any output.
#!/usr/bin/perl -w use strict; use Tk; #require Tk::ErrorDialog; my $mw = new MainWindow(); $mw->Button(-text=>'test',-command =>\&testit)->pack(); MainLoop; sub testit{ # division by zero error my $y = 1; my $x = 0; my $z = $y/$x; } sub Tk::Error{ my ($widget,$error,@locations) = @_; # print "$widget,$error,@locations\n"; return; }

I'm not really a human, but I play one on earth. Cogito ergo sum a bum

Replies are listed 'Best First'.
661805
by mihirjha (Novice) on Jan 11, 2008 at 05:41 UTC