{{ !articles[0].partner.isSponsoringArticle ? "Platinum" : "Portal" }} Partner
architects,high-perf,perl,performance,tips and tricks,node.js

Perl in Node.js

Yes, Perl5 can be embedded in node.js! First of all, do a npm install perl. (P.S. node-perl requires a perl5 binary built with -fPIC and -Duseshrplib.) This is synchronous but useful embedded Perl5 for node.js. If you want to try any version of perl, you must check out perl-node.

#>git clone git://github.com/hideo55/node-perl.git
#>cd node-perl
#>node-waf configure
#>node-waf build
#>node-waf install

And then:

var Perl = require('perl').Perl();
var perl = new Perl();
    opts : ["-Mfeature=say","-e","say 'Hello world'"]
}, function(out,err){
    script : 'example.pl',
    args : ['foo', 'bar']

If you opted for Perl5:

var Perl = require('perl-simple').Perl;
var perl = new Perl();
var ret = perl.evaluate("reverse 'yoeman'");
console.log(ret); // => nameoy
var Perl = require('../index.js').Perl;
var perl = new Perl();
var ua = perl.getClass('LWP::UserAgent').new();
var res = ua.get('http://utf-8.jp/');

Happy hacking!

Published at DZone with permission of {{ articles[0].authors[0].realName }}, DZone MVB. (source)

Opinions expressed by DZone contributors are their own.

{{ tag }}, {{tag}},

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}
{{ parent.authors[0].realName || parent.author}}

{{ parent.authors[0].tagline || parent.tagline }}

{{ parent.views }} ViewsClicks