in reply to Need Help: Capture STDOUT without Redirecting

I feel dirty for even suggesting it, but perldoc perlsub tells you how to override builtin functions. I hacked up an example overriding 'print' that called CORE::print twice - once to STDOUT and once to a filehandle, so I know 'print' can be overridden. That won't work for you: I needed to call my print as &print and you said you've no access to the sub.

I feel even dirtier suggesting you look into importing your print function into CORE::GLOBAL.

It's definitely dangerous, but hey, the functionality is there.

--
jpg
  • Comment on Re: Need Help: Capture STDOUT without Redirecting

Replies are listed 'Best First'.
Re^2: Need Help: Capture STDOUT without Redirecting
by ikegami (Patriarch) on May 04, 2006 at 22:13 UTC
    You can't override print, because of its weird syntax for accepting file handles. You can create functions called print, of course, but you can't override print. That's why you had to change print to &print.