in reply to Re^5: Overloading print()
in thread Overloading print()
Rmpfr_out_str (which wraps the mpfr library's mpfr_out_str function) prints directly to stdout, so I expected that output.txt would contain @NaN@ and the output to the console would look like:use warnings; use Math::MPFR qw(:mpfr); print "Hello world\n"; { local(*STDOUT); open(STDOUT, ">", "output.txt") or die $!; #line 10 $num = Math::MPFR->new(); #$num is a '@NaN@' Rmpfr_out_str($num, 10, 0, GMP_RNDN); close STDOUT; } print "Goodbye world\n";
However, output.txt is empty, and the console output looks like:Hello world Goodbye world
Apparently, redirecting perl's stdout has had no effect on xs's stdout. I guess I would need to redirect stdout from within the XSub.Hello world @NaN@Goodbye world
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^7: Overloading print()
by BrowserUk (Patriarch) on Sep 05, 2007 at 12:54 UTC |