tags:

views:

22

answers:

1

Sorry for the vague question .

I have a perl gui built in tk in linux . And I have built a text box in it . I wan to show the ouput of the perl script into the text box , including the errors or warnings that show up on the terminal when the perl script is run . How to do it ?

A: 

You could :

Open STDERR and STDOUT as in memory text files (you must close it first) :

close STDOUT;
open STDOUT, '>', \$variable or die "Can't open STDOUT: $!";
close STDERR;
open STDERR, '>', \$variable or die "Can't open STDERR: $!";

Much more on this could be found at open - perldoc.perl.org

Or catch warn and die statements:

$SIG{__WARN__} = sub { PrintThingsToMyLogWin(@_); 1 };
$SIG{__DIE__} = sub { PrintThingsToMyLogWin(@_); 1 };

But that won't allow you to catch standard print statements.

Any way, good luck finding a solution, and do not hesitate to tell us if you find it by yourself.

OMG_peanuts