Not only perl hackers but also the rest of hackers seem to make too much fun of PHP. That was so true that in YAPC::Asia even Matz and Larry was making fun of that (well, Larry made fun of every computer languages including perl but PHP part was the most horrendous).
I felt sorry for PHP folks so I came up with this. Ingy's Module::Compile made it so spiffy.
#!/usr/local/bin/perl use strict; use warnings; use Inline::PHP; no Inline::PHP; print "Hello, rest of the world!\n";
prints
Hello, PHP! Hello, rest of the world!And here is the module.
package Inline::PHP;
use 5.008001;
use strict;
use warnings;
our $VERSION = '0.01';
use Module::Compile -base;
sub pmc_compile {
my ($class, $html) = @_;
$html =~ s/no\s+$class\s*.*;\n//o;
open my $php, "|-" or exec 'php' or die $!;
print {$php} $html;
close $html;
return q();
}
1;
__END__
<?php echo "Enjoy!" ?>
Dan the Lambdaorz