On Sat, 29 Jul 2000, Chetan Patil wrote:

> Hello,
> We have a large code base printing header, body and footers to the STDOUT
> from the cgi scripts. Since all these are print statements, we have to go to
> extreme measures to make sure we donot print the content more than once.
> To clean things up (or at least start at it), we want to be able to trap the
> output of print to a local buffer and then selectively flush or junk based
> on the logic (for eg, if we decide to redirect at the end of the script,
> then we want to junk the buffer).
> I am looking for a quick solution which would allow me to override the
> CORE::print function and simply write to a buffer (a perl scalar). Once I am
> done with the processing, I can write out the buffer or junk it.
> Is it possible to do this? What should I be careful of?
> 
> THanks,
> Chetan
> 

chetan,

if you have to look into overridding perl's print function, you should
probably look into radically changing the structure of your program, imho.
if nothing else, build up the output you want to create and store it in a
scalar, then print that when you know it's ok.  better still, look into a
templating system (pls see threads from the last several days covering
this topic extensively) to divorce the output format from the logic of the
script.

ky


Reply via email to