Giter Site home page Giter Site logo

node-perl's Introduction

Synchronous but useful embedded Perl for node.js

This module is still working, but @tokuhirom don't want to maintain this module. MAINTAINER needed! Please contact me at github issues.

SYNOPSIS

var Perl = require('perl').Perl;
var perl = new Perl();
var ret = perl.evaluate("reverse 'yappo'");
console.log(ret); // => oppay

var Perl = require('../index.js').Perl;
var perl = new Perl();
perl.use('LWP::UserAgent');
var ua = perl.getClass('LWP::UserAgent').new();
var res = ua.get('http://utf-8.jp/');
console.log(res.as_string());

Classes

require('perl').Perl

var perl = new Perl()

Create new instance of Perl.

var retval = perl.evaluate(Str code)

evaluate the perl code and get a return value.

var klass = perl.getClass(Str name)

Get a class object(Instance of PerlClass) from perl.

var klass = Perl.blessed(obj)

Same as Scalar::Util::blessed.

var val = perl[funcname]

Get a PerlMethod object.

require('perl-simple').PerlObject

var val = obj[funcname]

Get a PerlMethod object.

require('perl-simple').PerlClass

You can get a instance of this class by Perl#getClass.

var val = klass[funcname]

Get a PerlMethod object.

require('perl-simple').PerlMethod

var val = method()

Call perl5 function and get a return value in scalar context. You get a exception when Perl5 throws exception.

var val = method.callList()

Same as above, but callList calls function in list context.

Installation

node-perl requires a perl5 binary built with -fPIC and -Duseshrplib. Normally, linux distribution's system perl is usable.

You can build a perl binary for node-perl with perlbrew command.

$ PERLBREW_CONFIGURE_FLAGS=-de perlbrew install perl-5.16.1 -Duseshrplib -Duseithreads -Dusethreads -Accflags='-fPIC' -nv
$ perlbrew use perl-5.16.1

On OSX

If you got a error while loading libperl.dylib, please set a DYLD_LIBRARY_PATH to perl5 library path.

Notes

  • The calls to Perl are synchronous ones.

THANKS TO

Based on https://github.com/hideo55/node-perl.

License

http://tokuhirom.mit-license.org/

node-perl's People

Contributors

tokuhirom avatar strikeforcezero avatar tyduptyler13 avatar darksmo avatar

Watchers

James Cloos avatar Eric Cirone avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.