# Ruby Module

**URL:** <https://www.ruby-forum.com/t/ruby-module/171653>\
**Category:** Ruby\
**Created:** [July 7, 2009, 9:26am UTC](https://www.ruby-forum.com/t/ruby-module/171653 "2009-07-07T09:26:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![vetrivel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/dc4da7/32.png) [@vetrivel](https://www.ruby-forum.com/u/vetrivel)\
**Post date:** [July 7, 2009, 9:26am UTC](https://www.ruby-forum.com/t/ruby-module/171653/1 "2009-07-07T09:26:28Z")

</div>

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 .

---

<div class="post-metadata">

**Author:** ![vetrivel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/dc4da7/32.png) [@vetrivel](https://www.ruby-forum.com/u/vetrivel)\
**Post date:** [July 7, 2009, 9:54am UTC](https://www.ruby-forum.com/t/ruby-module/171653/2 "2009-07-07T09:54:14Z")

</div>

2009/7/7 Vetrivel V. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> ```
> end
> 
> ```
> 
> 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

---

<div class="post-metadata">

**Author:** ![vetrivel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/dc4da7/32.png) [@vetrivel](https://www.ruby-forum.com/u/vetrivel)\
**Post date:** [July 7, 2009, 10:45am UTC](https://www.ruby-forum.com/t/ruby-module/171653/3 "2009-07-07T10:45:29Z")

</div>

Vetrivel V. 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’)
