From: "David A. Black" Date: 2004-02-04T21:35:53+09:00 Subject: Re: ARGV Hi -- On Wed, 4 Feb 2004, Artur Merke wrote: > Hi, > > how do I recognize if a ruby file prg.rb was called as a separate program > (from the command line) or was just included using require. Testing ARGV > for being nil doesn't seem to work See Ian's answer -- but also, just for future reference if needed, note that ARGV is never nil, but is an array (possibly an empty one). > ###################################################################### > # file= prg.rb > ###################################################################### > > if ARGV > print "called from command line" > end > > ###################################################################### > # file= prg2.rb > ###################################################################### > require 'prg.rb' > > print "now in prg2" Note also that the emptiness of ARGV will depend on how prg2.rb is called. So if you do: ruby prg2.rb abc ARGV will not be empty. David -- David A. Black dblack@wobblini.net