Slashdot Mirror


PHP and Perl in One Script?

gbulmash asks: "Recently, I began working on a graphics project and wanted to use ImageMagick. As a PHP coder, I figured I'd use MagickWand for PHP. But after some investigation, I decided that an alpha at 0.1.8 with sparse documentation just wasn't going to be good enough for production use. I decided that PerlMagick would be a much better API, but I didn't want to code the whole project in Perl. In the end, I found a cool package for embedding Perl code in PHP scripts (with an article on its use) and it went to a 1.0.0 release, earlier this year. I think I've found my answer, but before I make a final decision and go ahead with it, I thought I'd ask the knowledgeable Slashdot crowd: Is there a better way of interfacing Perl with PHP so you can get the best of both worlds?" So you've got Perl in your PHP, is there a way to do PHP in your Perl?

13 of 174 comments (clear)

  1. Re:If you use PHP.... by Anonymous Coward · · Score: 2, Funny

    I can't see any possibility of flamewars in this subject.

  2. It's like peanut butter and chocolate... by heinousjay · · Score: 5, Funny

    All the security of PHP and all the readability of Perl? It's a surefire win. I wonder why the whole world hasn't caught on to this one yet?

    --
    Slashdot - where whining about luck is the new way to make the world you want.
    1. Re:It's like peanut butter and chocolate... by Anonymous Coward · · Score: 4, Funny

      Dude #1: You got your Perl in my PHP!
      Dude #2: You got your PHP in my Perl!

      Announcer: Two great languages that only taste a little bit funny together. Now with less whitespace!!!

      Oh yeah, kids. Don't forget to try our other product, "Mac & PC". It's the cheesiest!

  3. Hey lover-boy by Anonymous Coward · · Score: 0, Funny

    > To be fair, they were plenty responsive the one time I asked for anything.

    That's enough about butt-sex, plz stay on topic in future.

  4. Hello there, Comrade Molotov! by mangu · · Score: 2, Funny

    Ahhh, nothing like a good flamewar! OK, I'll bite. Tell me, please, how do you write multidimensional arrays in Perl? No, no, you are *not* allowed to use references! Or what about a multidimensional hash? Suppose I wanted to migrate from PHP to Perl, how would I translate this perfectly valid PHP code to Perl:

    $x["a"]["b"]["c"] = "d";

    I mean, can you do it the Perl way, with less keystrokes?

  5. Ruby on Rails by Anonymous Coward · · Score: 5, Funny

    I'm probably going to get flamed for this but have you considered using rails? Seriously, you just spend a couple of hours installing it on your development box before you discover the speed and power of rails. Then when you've used the programming equivilent of a lumphammer to sculpt your fine detailed script, you get to spend the next week looking for hosting. I do all my development on a gentoo box, it only took me a weekend to set up from stage 1. I have some great USE flags that make my RAILS development go super fast and gentoo only takes about 1.5 hours a week to maintain. Well, sometimes it takes a little longer because the QA is non-existent of late.

    That's what I'd do anyway, RoR running on gentoo with some kicking USE flags. I'm developing a complete Ajax OS in my spare time using this system. It's going to revolutionize the OS market and yes, it will have use flags.

  6. Re:If you use PHP.... by Unnamed+Chickenheart · · Score: 3, Funny

    I am in no way an expert of programming nor web... ...but from my surfing experience, it seems like html + PHP creates very fast websides.

    (And PHP can do funky things like change colours on events like mouseover etc? groovy! )

    --
    urd
  7. Re:If you use PHP.... by Anonymous Coward · · Score: 2, Funny

    Come now, you sound like every other expert PHP programmer to me.

  8. Dear Slashdot, by edremy · · Score: 4, Funny
    I am trying to write a question that will get the maximum number of snarky replies. Taco didn't post my "Advice for converting a Ruby on Rails application to ASP.NET?" submission, so do you have another suggestion?

    Thank you
    A. T. Roll

    --
    "Seven Deadly Sins? I thought it was a to-do list!"
  9. Congratulations by Anonymous Coward · · Score: 2, Funny

    Congratulations! You found the worst of both worlds.

  10. Haven't you ever heard of that Loverboy song? by trentfoley · · Score: 2, Funny

    "Pearl and PHP DNA... just don't mix"

  11. Re:A bit extreme by billcopc · · Score: 3, Funny

    <? bighair() { ?>
    Shot through the code,
    and you're too lame.
    You give PHP
    a bad name.
    <? } ?>

    --
    -Billco, Fnarg.com
  12. 7 languages in one program by hallvar · · Score: 2, Funny

    http://blog.sykosopp.com/2006/02/26/one-file-to-ru le-them-all/

    Embed all your languages, this file can be interpreted or compiled in 7 different coding languages:

    $ php poly.sh.pl.php.tcl.cpp.bf.py.c.lhs.txt
    #I'm a PHP script
    $ python poly.sh.pl.php.tcl.cpp.bf.py.c.lhs.txt
    I'm a Python program.
    $ perl poly.sh.pl.php.tcl.cpp.bf.py.c.lhs.txt
    I'm a Perl program.
    $ tclsh poly.sh.pl.php.tcl.cpp.bf.py.c.lhs.txt
    I'm a tcl script.
    $ sh poly.sh.pl.php.tcl.cpp.bf.py.c.lhs.txt
    I'm a sh script.

    Rename file to compile in C/C++:

    $ gcc p.c -o c;./c
    I'm a C program (C89 with // comments, trigraphs disabled).
    $ g++ p.c -o cp;./cp
    I'm a C++ program, trigraphs disabled.

    --
    Hallvar Helleseth (hallvar)