Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I need to call a perl script from my php file.

I attempted to install the PECL extension for Perl.

I was unsuccessful.

I tried the following:

pecl channel-update pear.php.net
Updating channel "pear.php.net"
Update of Channel "pear.php.net" succeeded


pecl install perl
downloading perl-1.0.0.tgz ...
Starting to download perl-1.0.0.tgz (24,358 bytes)
.....done: 24,358 bytes
Validation Error: No release notes found
Parsing of package.xml from file "/tmp/pear/temp/peartf4IJH/package.xml" failed
Download of "pecl/perl" succeeded, but it is not a valid package archive
Error: cannot download "pear/perl"
Download failed
install failed

I am running a ubuntu server 12.10. My PHP version is

PHP 5.4.6-1ubuntu1.1 (cli) (built: Nov 15 2012 01:18:34) 
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies
with Xdebug v2.2.1, Copyright (c) 2002-2012, by Derick Rethans

My Perl version is

This is perl 5, version 14, subversion 2 (v5.14.2) built for x86_64-linux-gnu-thread-multi
(with 64 registered patches, see perl -V for more detail)

Copyright 1987-2011, Larry Wall

Update:

I tried the latest 23rd January 2013 Pecl install for Perl

It was labelled as 1.0.1

I got the following after running pecl install perl

downloading perl-1.0.1.tgz ...
Starting to download perl-1.0.1.tgz (25,282 bytes)
.........done: 25,282 bytes
5 source files, building
running: phpize
Configuring for:
PHP Api Version:         20100412
Zend Module Api No:      20100525
Zend Extension Api No:   220100525
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
    LANGUAGE = "en_SG:en",
    LC_ALL = (unset),
    LC_CTYPE = "UTF-8",
    LANG = "en_SG.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
    LANGUAGE = "en_SG:en",
    LC_ALL = (unset),
    LC_CTYPE = "UTF-8",
    LANG = "en_SG.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
building in /tmp/pear/temp/pear-build-rootcxwYP8/perl-1.0.1
running: /tmp/pear/temp/perl/configure
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for a sed that does not truncate output... /bin/sed
checking for cc... cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether cc accepts -g... yes
checking for cc option to accept ISO C89... none needed
checking how to run the C preprocessor... cc -E
checking for icc... no
checking for suncc... no
checking whether cc understands -c and -o together... yes
checking for system library directory... lib
checking if compiler supports -R... no
checking if compiler supports -Wl,-rpath,... yes
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking for PHP prefix... /usr
checking for PHP includes... -I/usr/include/php5 -I/usr/include/php5/main -I/usr/include/php5/TSRM -I/usr/include/php5/Zend -I/usr/include/php5/ext -I/usr/include/php5/ext/date/lib
checking for PHP extension directory... /usr/lib/php5/20100525
checking for PHP installed headers prefix... /usr/include/php5
checking if debug is enabled... no
checking if zts is enabled... no
checking for re2c... no
configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.
checking for gawk... no
checking for nawk... nawk
checking if nawk is broken... no
checking for perl support... yes, shared
checking how to print strings... printf
checking for a sed that does not truncate output... (cached) /bin/sed
checking for fgrep... /bin/grep -F
checking for ld used by cc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1572864
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... yes
checking how to convert x86_64-unknown-linux-gnu file names to x86_64-unknown-linux-gnu format... func_convert_file_noop
checking how to convert x86_64-unknown-linux-gnu file names to toolchain format... func_convert_file_noop
checking for /usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for ar... ar
checking for archiver @FILE support... @
checking for strip... strip
checking for ranlib... ranlib
checking for gawk... (cached) nawk
checking command to parse /usr/bin/nm -B output from cc object... ok
checking for sysroot... no
checking for mt... mt
checking if mt is a manifest tool... no
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if cc supports -fno-rtti -fno-exceptions... no
checking for cc option to produce PIC... -fPIC -DPIC
checking if cc PIC flag -fPIC -DPIC works... yes
checking if cc static flag -static works... yes
checking if cc supports -c -o file.o... yes
checking if cc supports -c -o file.o... (cached) yes
checking whether the cc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... no
configure: creating ./config.status
config.status: creating config.h
config.status: executing libtool commands
running: make
/bin/bash /tmp/pear/temp/pear-build-rootcxwYP8/perl-1.0.1/libtool --mode=compile cc  -I. -I/tmp/pear/temp/perl -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-rootcxwYP8/perl-1.0.1/include -I/tmp/pear/temp/pear-build-rootcxwYP8/perl-1.0.1/main -I/tmp/pear/temp/perl -I/usr/include/php5 -I/usr/include/php5/main -I/usr/include/php5/TSRM -I/usr/include/php5/Zend -I/usr/include/php5/ext -I/usr/include/php5/ext/date/lib  -DHAVE_CONFIG_H  -g -O2 -D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fstack-protector -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/lib/perl/5.14/CORE  -c /tmp/pear/temp/perl/php_perl.c -o php_perl.lo
libtool: compile:  cc -I. -I/tmp/pear/temp/perl -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-rootcxwYP8/perl-1.0.1/include -I/tmp/pear/temp/pear-build-rootcxwYP8/perl-1.0.1/main -I/tmp/pear/temp/perl -I/usr/include/php5 -I/usr/include/php5/main -I/usr/include/php5/TSRM -I/usr/include/php5/Zend -I/usr/include/php5/ext -I/usr/include/php5/ext/date/lib -DHAVE_CONFIG_H -g -O2 -D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fstack-protector -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/lib/perl/5.14/CORE -c /tmp/pear/temp/perl/php_perl.c  -fPIC -DPIC -o .libs/php_perl.o
/tmp/pear/temp/perl/php_perl.c:186:3: warning: initialization from incompatible pointer type [enabled by default]
/tmp/pear/temp/perl/php_perl.c:186:3: warning: (near initialization for 'php_perl_object_handlers.read_property') [enabled by default]
/tmp/pear/temp/perl/php_perl.c:187:3: warning: initialization from incompatible pointer type [enabled by default]
/tmp/pear/temp/perl/php_perl.c:187:3: warning: (near initialization for 'php_perl_object_handlers.write_property') [enabled by default]
/tmp/pear/temp/perl/php_perl.c:193:3: warning: initialization from incompatible pointer type [enabled by default]
/tmp/pear/temp/perl/php_perl.c:193:3: warning: (near initialization for 'php_perl_object_handlers.has_property') [enabled by default]
/tmp/pear/temp/perl/php_perl.c:194:3: warning: initialization from incompatible pointer type [enabled by default]
/tmp/pear/temp/perl/php_perl.c:194:3: warning: (near initialization for 'php_perl_object_handlers.unset_property') [enabled by default]
/tmp/pear/temp/perl/php_perl.c:198:3: warning: initialization from incompatible pointer type [enabled by default]
/tmp/pear/temp/perl/php_perl.c:198:3: warning: (near initialization for 'php_perl_object_handlers.get_method') [enabled by default]
/tmp/pear/temp/perl/php_perl.c:199:3: warning: initialization from incompatible pointer type [enabled by default]
/tmp/pear/temp/perl/php_perl.c:199:3: warning: (near initialization for 'php_perl_object_handlers.call_method') [enabled by default]
/tmp/pear/temp/perl/php_perl.c:202:3: warning: initialization from incompatible pointer type [enabled by default]
/tmp/pear/temp/perl/php_perl.c:202:3: warning: (near initialization for 'php_perl_object_handlers.get_class_name') [enabled by default]
/tmp/pear/temp/perl/php_perl.c:213:3: warning: initialization from incompatible pointer type [enabled by default]
/tmp/pear/temp/perl/php_perl.c:213:3: warning: (near initialization for 'php_perl_proxy_handlers.read_property') [enabled by default]
/tmp/pear/temp/perl/php_perl.c:214:3: warning: initialization from incompatible pointer type [enabled by default]
/tmp/pear/temp/perl/php_perl.c:214:3: warning: (near initialization for 'php_perl_proxy_handlers.write_property') [enabled by default]
/tmp/pear/temp/perl/php_perl.c:220:3: warning: initialization from incompatible pointer type [enabled by default]
/tmp/pear/temp/perl/php_perl.c:220:3: warning: (near initialization for 'php_perl_proxy_handlers.has_property') [enabled by default]
/tmp/pear/temp/perl/php_perl.c:221:3: warning: initialization from incompatible pointer type [enabled by default]
/tmp/pear/temp/perl/php_perl.c:221:3: warning: (near initialization for 'php_perl_proxy_handlers.unset_property') [enabled by default]
/tmp/pear/temp/perl/php_perl.c:225:3: warning: initialization from incompatible pointer type [enabled by default]
/tmp/pear/temp/perl/php_perl.c:225:3: warning: (near initialization for 'php_perl_proxy_handlers.get_method') [enabled by default]
/tmp/pear/temp/perl/php_perl.c:226:3: warning: initialization from incompatible pointer type [enabled by default]
/tmp/pear/temp/perl/php_perl.c:226:3: warning: (near initialization for 'php_perl_proxy_handlers.call_method') [enabled by default]
/tmp/pear/temp/perl/php_perl.c:229:3: warning: initialization from incompatible pointer type [enabled by default]
/tmp/pear/temp/perl/php_perl.c:229:3: warning: (near initialization for 'php_perl_proxy_handlers.get_class_name') [enabled by default]
/tmp/pear/temp/perl/php_perl.c:247:1: warning: excess elements in struct initializer [enabled by default]
/tmp/pear/temp/perl/php_perl.c:247:1: warning: (near initialization for 'php_perl_constructor_function') [enabled by default]
/tmp/pear/temp/perl/php_perl.c: In function 'php_perl_sv_to_zval_noref':
/tmp/pear/temp/perl/php_perl.c:540:7: warning: passing argument 3 of 'Perl_sv_2pv_flags' from incompatible pointer type [enabled by default]
In file included from /usr/lib/perl/5.14/CORE/perl.h:5036:0,
                 from /tmp/pear/temp/perl/php_perl.c:38:
/usr/lib/perl/5.14/CORE/proto.h:3565:21: note: expected 'STRLEN * const' but argument is of type 'int *'
/tmp/pear/temp/perl/php_perl.c:587:18: warning: format '%ld' expects argument of type 'long int', but argument 3 has type 'unsigned int' [-Wformat]
/tmp/pear/temp/perl/php_perl.c: In function 'php_perl_call_method':
/tmp/pear/temp/perl/php_perl.c:680:11: warning: passing argument 3 of 'Perl_sv_2pv_flags' from incompatible pointer type [enabled by default]
In file included from /usr/lib/perl/5.14/CORE/perl.h:5036:0,
                 from /tmp/pear/temp/perl/php_perl.c:38:
/usr/lib/perl/5.14/CORE/proto.h:3565:21: note: expected 'STRLEN * const' but argument is of type 'int *'
/tmp/pear/temp/perl/php_perl.c: In function 'php_perl_call':
/tmp/pear/temp/perl/php_perl.c:743:11: warning: passing argument 3 of 'Perl_sv_2pv_flags' from incompatible pointer type [enabled by default]
In file included from /usr/lib/perl/5.14/CORE/perl.h:5036:0,
                 from /tmp/pear/temp/perl/php_perl.c:38:
/usr/lib/perl/5.14/CORE/proto.h:3565:21: note: expected 'STRLEN * const' but argument is of type 'int *'
/tmp/pear/temp/perl/php_perl.c: In function 'php_perl_get_method':
/tmp/pear/temp/perl/php_perl.c:1418:5: error: too few arguments to function 'zend_get_std_object_handlers()->get_method'
/tmp/pear/temp/perl/php_perl.c: In function 'php_perl_get_properties':
/tmp/pear/temp/perl/php_perl.c:1496:29: error: 'znode_op' has no member named 'op_type'
/tmp/pear/temp/perl/php_perl.c:1497:29: error: 'znode_op' has no member named 'u'
/tmp/pear/temp/perl/php_perl.c:1498:12: error: 'znode_op' has no member named 'u'
/tmp/pear/temp/perl/php_perl.c:1498:12: error: 'znode_op' has no member named 'u'
/tmp/pear/temp/perl/php_perl.c:1499:12: error: 'znode_op' has no member named 'u'
/tmp/pear/temp/perl/php_perl.c:1499:12: error: 'znode_op' has no member named 'u'
/tmp/pear/temp/perl/php_perl.c:1500:12: error: 'znode_op' has no member named 'u'
/tmp/pear/temp/perl/php_perl.c:1500:12: error: 'znode_op' has no member named 'u'
/tmp/pear/temp/perl/php_perl.c:1501:12: error: 'znode_op' has no member named 'u'
/tmp/pear/temp/perl/php_perl.c:1501:12: error: 'znode_op' has no member named 'u'
/tmp/pear/temp/perl/php_perl.c:1502:12: error: 'znode_op' has no member named 'u'
/tmp/pear/temp/perl/php_perl.c:1502:12: error: 'znode_op' has no member named 'u'
/tmp/pear/temp/perl/php_perl.c: In function 'php_perl_clone':
/tmp/pear/temp/perl/php_perl.c:1666:7: warning: format '%ld' expects argument of type 'long int', but argument 3 has type 'unsigned int' [-Wformat]
/tmp/pear/temp/perl/php_perl.c: In function 'zm_info_perl':
/tmp/pear/temp/perl/php_perl.c:1843:3: warning: unknown conversion type character 'v' in format [-Wformat]
/tmp/pear/temp/perl/php_perl.c: In function 'zim_Perl_eval':
/tmp/pear/temp/perl/php_perl.c:1905:13: warning: passing argument 3 of 'Perl_sv_2pv_flags' from incompatible pointer type [enabled by default]
In file included from /usr/lib/perl/5.14/CORE/perl.h:5036:0,
                 from /tmp/pear/temp/perl/php_perl.c:38:
/usr/lib/perl/5.14/CORE/proto.h:3565:21: note: expected 'STRLEN * const' but argument is of type 'int *'
make: *** [php_perl.lo] Error 1
ERROR: `make' failed
www-data@ubuntu-server:/var/virtual/storyzer.com/testperl$ exit
logout
share|improve this question
    
You might want to try again, there seems to be a new build of perl (v1.0.1) one day after you posted your question. –  uzyn Jan 28 '13 at 6:43
    
thank you, @uzyn I got another set of errors after trying the new build –  Kim Stacks Jan 29 '13 at 0:56
add comment

1 Answer

up vote 0 down vote accepted

This answer works as of 29 Jan 2013.

First of all, inside ubuntu do

wget http://pecl.php.net/get/perl-1.0.1.tgz

to download the tgz file from http://pecl.php.net/package/perl

Unzip the tar

tar -zxvf perl-1.0.1.tgz

Go into the uncompressed folder

cd perl-1.0.1

Remove the current php_perl.c because for some reason, it did not work with my php5.

Download another php_perl.c from github repo https://github.com/do-aki/php-ext-perl

wget https://raw.github.com/do-aki/php-ext-perl/a3d7db22eb7964ea9cb39ea2f866d10df26655d4/php_perl.c

Run this line by line

export PHP_PREFIX="/usr"
export PERL_PREFIX="/usr"
$PHP_PREFIX/bin/phpize
./configure --with-perl=$PERL_PREFIX --with-php-config=$PHP_PREFIX/bin/php-config
make  

If you get errors like /usr/bin/ld: cannot find -lperl, then you need to install

sudo apt-get install libperl-dev

Install the extension (this step can require root privileges)

make install

Add perl extension into your php.ini (this step can require root privileges)

extension=perl.so

Restart your php5-fpm

sudo /etc/init.d/php5-fpm restart

You may get issues to do with locale when you run Perl.

Look at the missing locales. Assuming you have missing en_SG and en_SG.UTF-8

Try

sudo locale-gen en_SG en_SG.UTF-8
sudo dpkg-reconfigure locales

and then reboot.

If you still have locale issues,

Try

sudo nano /etc/environment

Append the missing locale to LC_ALL

LC_ALL = "en_SG.UTF-8"

Reboot.

I want to thank tm064 from #perl and NullDev from #ubuntu for helping me with this solution.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.