http://www.perlmonks.org?node_id=87842


in reply to framechat

Once again epoptai++ for this really nice update.

Here's a patch for the mod_perl users which allows them to run framechat with mod_perl. This is really faster than the regular version because the whole script is only loaded once, and all the script has to do then is to fetch the XML and print it.

It is implemented as a Apache::Registry handler, if I got some time and if there's enough interest, I could maybe come up with a full blown Apache::Framechat for all the CB addicts around.

#!/usr/bin/perl open (CGI, $ARGV[0]) or die "Cannot open $ARGV[0]:$!\n"; open (MOD, "> mod_framechat.pl") or die "Cannot open mod_framechat.pl: +$!\n"; { local $/; $cgi = <CGI>; } # you know epoptai's spacebar sometime stuck... :P $cgi =~ s[my\s*%i\s*=\s*map\s*{\s*\$_\s*=>\s*param\(\$_\)}\s*param;][$ +&;\nsub mod_perl_run {]is; $cgi =~ s[</noframes></html>~;.exit][$&\n}]is; $cgi =~ s[^__END__][=cut]is; print MOD $cgi . "\n'mod_perl is cool.';"; open (MOD2, "> launch_framechat.pl") or die "Cannot open launch_framec +hat.pl:$!\n"; print MOD2 <<'__script__'; #!perl use strict; require "./mod_framechat.pl"; mod_perl_run(); __script__ print STDERR "Done. You can now run launch_framechat.pl!\n";

framechat2 mod-perl

#!/usr/bin/perl open (CGI, $ARGV[0]) or die "Cannot open $ARGV[0]:$!\n"; open (MOD, "> mod_framechat.pl") or die "Cannot open mod_framechat.pl: +$!\n"; { local $/; $cgi = <CGI>; } # you know epoptai's spacebar sometime stuck... :P $cgi =~ s[# mod_perl_patch_begin][# mod_perl_patch_begin\nsub mod_perl +_run {]is; $cgi =~ s[# mod_perl_patch_end][# mod_perl_patch_end\n}]is; print MOD $cgi . "\n1;"; open (MOD2, "> launch_framechat.pl") or die "Cannot open launch_framec +hat.pl:$!\n"; print MOD2 <<'__script__'; #!perl use strict; require "./mod_framechat.pl"; mod_perl_run(); __script__ print STDERR "Done. You can now run launch_framechat.pl!\n";

20010613 - update: Fixed the __END__ token problem, and returns a true value;

20010825 - update: Updated the patch for framechat2

<kbd>--
my $OeufMayo = new PerlMonger::Paris({http => 'paris.mongueurs.net'});</kbd>