Inline::PHP

dankogai on 2006-04-01T07:23:17

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


Dan Kogai on ruby

mr_bean on 2006-04-01T12:15:50

Larry is funny, but sectarianism isn't funny. How can we make sectarianism funny?

Anyway. Thanks to Dan for non-sectarianism in the area of computer languages.

Dan had this to say about Matz, who spoke at YAPC::Asia this week, in his Japanese blog at http://blog.livedoor.jp/dankogai/archives/50434635.html

When you think about the fact that, if there hadn't been ruby, perl might have rested on its laurels, in a sense at this point in time, the perl community's biggest contributor is Matz.