Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Zsh perl module



        Well, I've gotten several mails indicating interest in my perl 
module.  I've got a rough (*very rough*) patch ready and on the web:

http://www.phydeaux.org/perl/zperl-0.01.patch.gz


        Something along the lines of the following should (in theory)
get you a zperl.so that can be zmodload'd when run against a copy of
the zsh-3.1.6 source tree:


cd ..../zsh-3.1.6
gunzip < zperl-0.01.patch.gz | patch -p1
./configure ...         # may not be needed if already configured

cd Src
make modules            # this will fail, see below

cd Modules/zperl
sh ./makezperl          # this is a kludge

cd Zsh                  # Then install the perl side of things
perl Makefile.PL && make install


        As I said, it's rough at the moment.  Any sugguestions how to
get perl's cflags and ldflags into the mdd file in the correct way
would be welcome (they're generated with something like:

        `perl -MExtUtils::Embed -e ccopts`

and the objects="" setting didn't like having -lfoolib in it).


        There's not really any documentation to speak of, but the
commands are (once you've done `zmodload zperl.so'):

List any perl defined builtins commands 
zperl -l 

Have the perl interpreter require a perl module
zperl -r Perl::Module

Define a zsh builtin as a perl subroutine
zperl -b foo Perl::Sub

Undefine a builtin defined by zperl -b
zperl -u foo


        I've been using a perl module along the following lines for
testing.  Put this in a file named Ztest.pm somewhere that perl can
find it and do `zperl -r Ztest ; zperl -b perl_eval Ztest::eval'.  You 
can then evaluate arbitrary perl code with the new `perl_eval'
command.

---->8 Cut Here 8<----
package Ztest;

use Zsh;

sub eval {
  my $code = shift;

  eval " $code ";

  if( $@ ) {
    warn "Error during eval: $@\n";
    return 1;
  } else {
    return 0;
  }
}

1;

__END__
---->8 Cut Here 8<----

-- 
Fletch                | "If you find my answers frightening,       __`'/|
fletch@xxxxxxxxxxxx   |  Vincent, you should cease askin'          \ o.O'
678 443-6239(w)       |  scary questions." -- Jules                =(___)=
                      |                                               U



Messages sorted by: Reverse Date, Date, Thread, Author