Then you would mess up someone who had inserted:
print STDERR "Called node 'foo'\n";
as a debugging aid. (The messsage should show up in your
webserver's logs.) The following (untested) code is much
nicer:
package noprint;
use Carp;
sub PRINT {
my $msg = Carp::longmess("You must return rather than print");
print "Content-type: text/plain\n\n$msg";
die $msg;
}
*PRINTF = *PRINT;
sub TIEHANDLE {
return bless ({}, shift);
}
and elsewhere in the code:
tie(*NOPRINT, 'noprint');
select(NOPRINT);
# time passes while the page is built.
# Before spitting out the final page:
select(STDOUT);
That catches the newbie error. Without the potential for headaches that overriding
print causes.