L
Loga Ganesan
Below code is used for calling c function in ruby.
#! /usr/bin/ruby
require '/usr/lib/ruby/1.8/inline.rb'
puts "Inline module......"
class MyTest
inline do |builder|
builder.c "
long factorial(int max) {
int i=max, result=1;
while (i >= 2) { result *= i--; }
return result;
}"
end
end
t = MyTest.new()
fact = t.factorial(5)
puts fact
Question:
Likewise, instead of c I have to write a perl function and should call
it?
Is there any way?
#! /usr/bin/ruby
require '/usr/lib/ruby/1.8/inline.rb'
puts "Inline module......"
class MyTest
inline do |builder|
builder.c "
long factorial(int max) {
int i=max, result=1;
while (i >= 2) { result *= i--; }
return result;
}"
end
end
t = MyTest.new()
fact = t.factorial(5)
puts fact
Question:
Likewise, instead of c I have to write a perl function and should call
it?
Is there any way?