Re: Perl extension for PHP
| From: | Jesus M. Castagnetto | Date: | Sat, 03 May 2003 20:04:24 +0000 |
| Subject: | Re: Perl extension for PHP | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-15812@lists.php.net to get a copy of this message | ||
Is this similar to the perl-in-php extension?
(http://msalem.translator.cx/perlinphp.php)
In any case, I think it would be OK to have in PECL. That will complement the
hooks from PHP to the other languages most people use: Java, Python and Perl,
not to forget InlineC.
At some point I tried to have perl-in-php, the PECL python and the Java
extension working, but had not much luck on my old Solaris box. Perhaps I
should try again just to be devious ;-)
+1 for inclusion to PECL with a caveat.
The caveat is that I had not compiled/tested it yet, just took a quick look at
the C code and the example.
One thing though. Perhaps it will be good to have *real* INI entries registered
in the code, if you need them, and not add '42' and 'foobar' <grin>. Some
of
the tools we have made for the documentation will extract those when adding
them to the manual entry, and that will look funny.
Also, talking to the author of 'perl-in-php' might also be good to see what
code can be shared to improve the final extension.
--- Johannes Schlueter <phpng@schlueters.de> wrote:
> Hi there,
>
> Summary
> =======
>
> I've written a PHP Extension to embed a perl interpreter to PHP
> and would like to publish it via pear/pecl.
>
> Requirements
> ============
>
> PHP 4.2.2, 4.2.3, 4.3, 4.3.1 (tested versions)
> Perl 5.8.0 (due to API changes no older versions supported)
> Tested using a Linux box
>
> What can it do
> ==============
>
> At the moment this is a rather simple extension, if enough
> people are interested in it I can spend more time on it.
> At the moment you can create an perl interpreter, let the
> interpreter eval some perl code, execute a perl sub and
> manipulate (read/write) scalar perl variables using a few
> PHP-Extension functions.
> the prototypes of thes functions look like
>
> void perl_init(void)
> Inits the perl interpreter
> bool perl_eval(string source)
> Parses and executes some perl code given as paramter
> mixed perl_call(string name, [array param])
> Calls a perl sub called name with the paramters param
> Returns the perl return value if perl returns a scalar
> variable, only scalar paramters in param alloud
> mixed perl_get_var(string name)
> Returns the value of the (scalar) parl variable name.
> name needs to be in global context of the perl-script
> bool perl_set_var(string name, mixed value)
> Sets the perl variable name with the value value
>
> Where required this extension does a little typecasting
> between perl and PHP values. (PHP bool -> perl int, scalar
> variables hold their type, other types arn't supported, yet)
>
> Usage
> =====
>
> see included example perl.php
>
> Problems
> ========
>
> - C-written perl modules don't work (see perlembed(1) about
> compiling embeded perl interpreters using perl modules
> - Accessing non-existing variables or eval'ing bad perl-code
> might result in segfaults
> - print-calls in perl scripts while using an PHP-SPI different
> from CLI or CGI are not send to the zend output stream but
> somewhere
>
> Installation:
> =============
>
> Fetch http://www.schlueters.de/perl-pre0.1.tar.bz2 extract it
> to php-src/ext/ configure PHP using --with-perl=DIR were DIR
> is the location of perl.h and libperl.so (on my box, both are
> located at /usr/lib/perl5/5.8.0/i686-linux/CORE/). I didn't
> manage compiling it using phpize, I'd be glad if someone could
> help me with that.
>
> About me
> ========
> Just a few sentences about the guy how has to much spare time:
> I'm a 21 year old student, living at Munich/Germany. I'm
> using computers since I'm 14 years old, my first PHP scripts
> are dated on April 25th, 2000.
>
>
> Now I'd like to get some comments on this thing here and mybe
> even some +1 for adding it to pear, a better documentation
> is in work, but the explainations above and the example
> script should help you out ;-)
>
> johannes
>
> --
> PEAR Development Mailing List (http://pear.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
=====
--- Jesus M. Castagnetto (jcastagnetto@yahoo.com)
Research:
http://metallo.scripps.edu/
Personal: http://www.castagnetto.org/
__________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
http://search.yahoo.com