DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Newsletter
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Node.js Microservices Architecture: A Complete Guide
  • Refresh Token Rotation in Node.js: Stopping Token Theft Without Logging Users Out
  • Stop Writing Dialect-Specific SQL: A Unified Query Builder for Node.js
  • Lambda-Driven API Design: Building Composable Node.js Endpoints With Functional Primitives

Trending

  • Build Software Faster With Three Simple Principles
  • Building a Practical Cloud-Native Golden Path: A Guide to Kubernetes-Based Service Delivery, Self-Service, and Developer-Friendly Defaults
  • Detection and Response Did Its Job. Now Someone Has to Actually Fix It.
  • Introducing senro: A Pipeline Engine You Program in Go

Draft This article hasn't been published, so readers can't see it.

In moderation This article is waiting for review, so readers can't see it yet.

Deleted This article has been deleted, so readers can't see it.

  1. DZone
  2. Coding
  3. JavaScript
  4. Perl in Node.js

Perl in Node.js

By 
Hemanth HM
·
Sep. 14, 12 · Interview
Post on X (opens in a new tab) Share on LinkedIn (opens in a new tab)
17.3K Views

Join the DZone community Save articles, join the discussion, and download Refcards and Trend Reports with a free account.

Join for free Already a member? Log in

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();
 
perl.Run({
    opts : ["-Mfeature=say","-e","say 'Hello world'"]
}, function(out,err){
    console.log(out);
});
 
perl.Run({
    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();
perl.use('LWP::UserAgent');
var ua = perl.getClass('LWP::UserAgent').new();
var res = ua.get('http://utf-8.jp/');
console.log(res.as_string());

Happy hacking!

Node.js Perl (programming language)

Published at DZone with permission of Hemanth HM. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Node.js Microservices Architecture: A Complete Guide
  • Refresh Token Rotation in Node.js: Stopping Token Theft Without Logging Users Out
  • Stop Writing Dialect-Specific SQL: A Unified Query Builder for Node.js
  • Lambda-Driven API Design: Building Composable Node.js Endpoints With Functional Primitives

Partner Resources

×

Comments

Loading comments

The comments didn't load

Please try again in a moment.

Likes

Loading

The next likes didn't load. Please try again.

The likes didn't load

Please try again in a moment.

See who liked this

Log in or join DZone for free to see who liked this article.

Log in Join for free
  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook