Skip to content

Instantly share code, notes, and snippets.

@threez
Created May 5, 2015 13:57
Show Gist options
  • Save threez/2fc92a0aac1f767852ca to your computer and use it in GitHub Desktop.
Save threez/2fc92a0aac1f767852ca to your computer and use it in GitHub Desktop.
Simply execute perl code from ruby
require 'open3'
module Perl
def self.exec(code)
pstdin, pstdout, pstderr = Open3.popen3('perl')
pstdin.write code
pstdin.close
data = pstdout.read
err = pstderr.read
if err.size > 0
raise err
end
data
ensure
pstdout.close
pstderr.close
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment