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?
Instead of going with some bizarre rube-goldberg hack like this (does it even work with dynamically loadable Perl modules?), just write a separate Perl script that does what you need and receives data on standard input and gives responses on standard output. Use PHP's proc_open() function. You can even set up the Perl script as a daemon, if you like, and get higher performance.
I used this same trick to interface a binary-only executable to my PHP script. You can even use XML to pass the data back and forth, if you swing that way. I don't know how this might work on Windows, if that's what you're running on.
By the way, version numbers mean absolutely nothing except the author's opinion of his own software. In fact, the article you posted says: "the extension is still marked EXPERIMENTAL". Sounds like alpha to me.
Not to mention, this is the same guy that wrote Turck MMCache and in my testing, mmcache couldn't stay stable for more than a day or two, and would randomly return junk characters instead of output from our PHP scripts. Not exactly an author I'd trust for this kind of lower-level stuff. (Yeah, I know, there are 10 billion geeks who used MMCache on their 5-hit-per-day blog and it worked perfectly, and will not hesitate to point this out. It just didn't work for me, and other products did, sorry!)
For what it's worth, I've used "pecl-imagick-0.9.11" on my Gentoo servers to manipulate images (basically, to generate thumbnails by resizing and sharpening) and it works perfectly. I think this is different than what you're talking about. So unless you really just can't live without Perl (?), try that first.
Instead of looking at version numbers, test thoroughly.
as almost always, CPAN is your friend in all things perl-related.
aside from that, i really don't understand why you'd use PHP if you're familiar enough with perl to use it.
As Iunderstand it ... Mason, a perl based web authoring kit has been used by quite a few web sites, including Amazon.
... I guess their website is just painfully slow and prone to problems.
Yeah
This space for rent. All reasonable inquiries will be entertained at proprietors discretion.
Huh, some perl driven web apps:
http://www.slashcode.com/
http://scoop.kuro5hin.org/
I have been trolled. Hope this helps. Have a nice day.
Personally I prefer Java Servlets, with perl a second place, then python, then bash, then C, then php.
Start Running Better Polls
Erm... how about
Yes, it uses references, but if you're scared of them, pretend it's a 'real' multidimensional hash.
I tend to use ImageMagick a lot via PHP scripts, but not with any sort of polyglot of code or anything – I just use exec("convert ... ");. It's probably not the most cross-platform way, but since I tend to do exclusively Linux/UNIX-based stuff, and most of the code is only used by me for my own sites anyway, it's not a problem at least as far as I'm concerned.
Creative misinterpretation is your friend.
$y[0][0][0] = 0;
$x{a}{b}{c} = 'd';
Beat you by 6 characters on that second one. And if I'm not allowed to use references, you're not allowed to use strings. Perl is designed with references in mind.
To smash a single atom, all mankind was intent / Now any day the atom may return the compliment
Whoa, not for lexicals.
Nope, only after you've already dereferenced one level.
how to invest, a novice's guide
There's like ten bazillion ways to integrate PHP with Image processing tools like Image Magick just like with any other OSS language. Only more so because the PHP userbase is largest. No need to use some Hack involving Perl. Typo3 (www.typo3.org) uses Image Processing to generate Menubuttons and stuff, there are countless other PHP projects out there doing the same, and it's no sweat at all to start the imagemagick CLI tools (contvert, etc.) including parameters from PHP. 30 lines of code max I'd say. Do you homework and then ask in some PHP forums and mailinglists for sample code. You'll get answers in no time.
We suffer more in our imagination than in reality. - Seneca
Why do you need them to work in the same script? Have your PHP generate an img tag that references the perl script in the src attribute. Then the web browser will fetch the image data directly from the perl script and you don't need a Frankensteinian monster.
Just wondering. :-)
Using too many languages is bad?
Hell, then a page of mine that uses all of:
* bash
* C
* C++
* Perl
* perhaps even Python or some such (hell, I don't look under the pants of programs I call)
* sed
* grep
And as far as I know, this is not a rare practice. If it's not a CPU-critical script, bash makes for good glue code. And you can't call it hard to maintain (at least until you look at sourceless configure scripts).
The creatures outside looked from Alt-Right to Antifa; but already it was impossible to say which was which.
I am in the joyous position of having to maintain a monstrosity of an application that was written by at least 4 different programmers over a period of years with numerous kludges plastered on top of a highly dodgy initial design.
A lot of the early code was in Perl. Obfuscated, unreadable, indecipherable (and uncommented) Perl. So I decided to re-implement whole libraries of functions in PHP instead. But...a lot of what goes on in the application is driven by 2 Perl daemons, and they needed access to the new PHP libraries too.
So:
Day by day, the penguins steal my sanity