Stories
Slash Boxes
Comments

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

dankogai (3580)

dankogai
  (email not shown publicly)

Journal of dankogai (3580)

Saturday April 01, 2006
03:23 AM

Inline::PHP

[ #29171 ]

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;
<?php echo "Hello, PHP\n" ?>
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

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • 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 [livedoor.jp] 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.