Ik heb een probleem met het printen naar een logfile in mod_perl. Zonder mod_perl ziet het er zo uit (werkend):
Wanneer ik dit stuk code onder mod_perl draait werkt het niet, er wordt geen logfile aangemaakt. Ik heb begrepen dat mod_perl hiet inderdaad anders te werk gaat (http://take23.org/docs/guide/porting.xml/18) :
In mod_perl both STDIN and STDOUT are tied to the socket the request came from. Because the C level STDOUT is not hooked up to the client, you can re-open the STDOUT filehandler using tie(). For example if you want to dup an STDOUT filehandler and for the code to work with mod_perl and without it, the following example will do:
[code]
use constant IS_MODPERL => $ENV{MOD_PERL};
if (IS_MODPERL) {
tie *OUT, 'Apache';
} else {
open (OUT, ">-");
}
[/code]
Ik heb dit geprobeerd, maar er wordt nog steeds geen logfile aangemaakt. Ik snap ook niet helemaal wat bovenstaand stukje code doet, moet er nergens een filenaam aangegeven worden? Heeft iemand een werkende oplossing?
code:
1
2
3
| open(LOG, ">>program.log"); print LOG "bla"; close (LOG); |
Wanneer ik dit stuk code onder mod_perl draait werkt het niet, er wordt geen logfile aangemaakt. Ik heb begrepen dat mod_perl hiet inderdaad anders te werk gaat (http://take23.org/docs/guide/porting.xml/18) :
In mod_perl both STDIN and STDOUT are tied to the socket the request came from. Because the C level STDOUT is not hooked up to the client, you can re-open the STDOUT filehandler using tie(). For example if you want to dup an STDOUT filehandler and for the code to work with mod_perl and without it, the following example will do:
[code]
use constant IS_MODPERL => $ENV{MOD_PERL};
if (IS_MODPERL) {
tie *OUT, 'Apache';
} else {
open (OUT, ">-");
}
[/code]
Ik heb dit geprobeerd, maar er wordt nog steeds geen logfile aangemaakt. Ik snap ook niet helemaal wat bovenstaand stukje code doet, moet er nergens een filenaam aangegeven worden? Heeft iemand een werkende oplossing?