There is a number of choices some of which have been mentioned already. 
What is appropriate depends on the use case which is not entirely clear.

1. Use a command line option to transfer the value.  This is most 
explicit and makes the interface of the sub process visible.  Conversion 
can even be made automatic with OptionParser.

2. Get rid of the split into two processes.  Since the call is 
synchronous your calling process must wait anyway so it can as well do 
all the processing.  This may introduce memory leaks though depending on 
the code in WWW.rb and the lifetime of the calling process.

3. Set an environment variable (via ENV) before invoking the other Ruby 
process which then can read the value from there.  This is far less 
obvious than the variant mentioned before and requires additional 
conversion if other values than strings must be transferred.

4. Keep the local variable but instead of system use fork and load. 
This avoids conversions but some care should be taken with regard to 
open file descriptors.

Of course you can invent even more complex schemes (e.g. two processes 
with DRb connection) but I have the impression that you are reinventing 
the wheel.  There are working solutions for web services already.

Kind regards

robert

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