# Calling Perl script from Ruby

**URL:** <https://www.ruby-forum.com/t/calling-perl-script-from-ruby/73127>\
**Category:** Ruby\
**Created:** [October 21, 2006, 7:52pm UTC](https://www.ruby-forum.com/t/calling-perl-script-from-ruby/73127 "2006-10-21T19:52:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dracos](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ea666f/32.png) [@dracos](https://www.ruby-forum.com/u/dracos)\
**Post date:** [October 21, 2006, 7:52pm UTC](https://www.ruby-forum.com/t/calling-perl-script-from-ruby/73127/1 "2006-10-21T19:52:24Z")

</div>

Hi,

I have a Perl script that takes an input and outputs a string. I would  
like to call this Perl script from my Ruby script and have the string  
appear in my Ruby script after.

I was thinking I would use the command line of my system as the middle  
man. Looking at Ruby’s Kernel#system it only returns true or false if  
the command is found and ran successfully or not. I would like to get  
that string instead of true if possible.

I am hoping to avoid complicated things like having the Perl write to a  
file and then read that file into Ruby.

Any suggestions?

Thank you,  
Peter

---

<div class="post-metadata">

**Author:** ![dracos](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ea666f/32.png) [@dracos](https://www.ruby-forum.com/u/dracos)\
**Post date:** [October 21, 2006, 8:02pm UTC](https://www.ruby-forum.com/t/calling-perl-script-from-ruby/73127/2 "2006-10-21T20:02:27Z")

</div>

On Sun, Oct 22, 2006 at 02:50:14AM +0900, Peter M. wrote:

> Hi,
> 
> I have a Perl script that takes an input and outputs a string. I would  
> like to call this Perl script from my Ruby script and have the string  
> appear in my Ruby script after.  
> […]  
> Any suggestions?

```
Just do:

output = `perl myperlscript.pl arg1 arg2`

```

That should do the trick. You also have open3 and others, if you want  
more  
fine-grained control of input and outputs.

```
HTH,
```
