http://qs321.pair.com?node_id=1212810


in reply to Override printing to STDOUT/ERR

I'm still confused about the use case....

If this is only for debugging purpose to find the line numbers , you can close STDOUT and STDERR and cause warnings. But the string to be printed will be lost.

DB<6> close STDOUT DB<7> use warnings; print 666 print() on closed filehandle STDOUT at (eval 15)

Otherwise I concur with Corion to tie a filehandle. caller will tell you where the tied method was called and you can redirect STDOUT and STDERR to these FHs. (also with select )

Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Wikisyntax for the Monastery