![]() |
|
Perl: the Markov chain saw | |
PerlMonks |
Re: overloading the print function (or alternatives)by chipmunk (Parson) |
on Dec 04, 2000 at 10:42 UTC ( [id://44750]=note: print w/replies, xml ) | Need Help?? |
Personally, I am leery of working around the problem as you are asking. So, here are my ideas, in order of preference, most preferred first.
1. I don't know much about the Everything Engine, but I wonder if it is possible to simply output the content-type header at the beginning of the program, before the programmer's code is called. 2. I would want to educate the users not to make this mistake. Of course, that can be difficult, because every new user may need to be educated about this issue. That can end up being more work than just fixing the problem. :) 3. Overload the print function. I'm not sure offhand whether print is in the list of built-in functions that can be overloaded. Someone else can address this one. :)
4. Tie the output filehandle. Tying a filehandle other than STDOUT and selecting it would be fine, except what if a programmer prints explicitly to STDOUT? (e.g. print STDOUT "hello $USER->{title}")
Refer to perltie for more on tied filehandles and tying in general.
In Section
Seekers of Perl Wisdom
|
|