Ruby Module

I have written some of the funcions in a file . The filename is test.rb
Examples
test.rb has only the following functions .
             def hai(a,b)
                  puts "This is Hai"
             end

             def hellow
                  puts "This is Hellow"
             end

In check.rb I have required test.rb file . Then I used below hai method.
It works .
The check.rb file has
       require 'test'
       hai(1,2)

When I running this program in command line it works . But I am calling
check.rb program from perl using system call . Some times it works fine
. Some time It doesn't work . I got some error in my code . The Error
is ' Wrong no of argument error' .
     system(check.rb).
I am running above code from perl . To check the problem , I am
redirecting the stderr to a file . I got Wrong 'no of argument error' .

check.rb is an executable file .

My Solution
         I think that we should not require a file without module . I
request you t share your experience .

···

--
Posted via http://www.ruby-forum.com/.

I have written some of the funcions in a file . The filename is test.rb
Examples
test.rb has only the following functions .
def hai(a,b)
puts "This is Hai"
end

        def hellow
             puts "This is Hellow"
        end

In check.rb I have required test.rb file . Then I used below hai method.
It works .
The check.rb file has
require 'test'
hai(1,2)

When I running this program in command line it works . But I am calling
check.rb program from perl using system call . Some times it works fine
. Some time It doesn't work . I got some error in my code . The Error
is ' Wrong no of argument error' .
system(check.rb).
I am running above code from perl . To check the problem , I am
redirecting the stderr to a file . I got Wrong 'no of argument error' .

check.rb is an executable file .

Do you have set the shebang line properly? Did you make sure that
your load path is configured in a way that check.rb finds the proper
test.rb?

My Solution
I think that we should not require a file without module .

I am not sure what you are trying to say here but I doubt that this
will solve your issue.

I request you t share your experience .

A better way to put this would have been "please share your experience".

Regards

robert

···

2009/7/7 Vetrivel Vetrivel <vetrivel.bksys@gmail.com>:

--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/

Vetrivel Vetrivel wrote:

I am running above code from perl . To check the problem , I am
redirecting the stderr to a file . I got Wrong 'no of argument error' .

Can you paste the *exact* and *complete* error message you see? This
will make it clear whether the error comes from Perl or Ruby, and if
Ruby, exactly which line it is on.

The only problem I can see is that "require 'test'" assumes that test.rb
is in the current working directory. Perl may have changed the current
working directory. You could write instead:

  require File.join(File.dirname(__FILE__), 'test')

···

--
Posted via http://www.ruby-forum.com/\.