Gene Tani wrote:
> Tim Hammerquist wrote:
> 
>> BTW, $0 and $PROGRAM_NAME are aliases for the same variable.
>> 
> 
> "__FILE__", too, I guess

Nope.  __FILE__ is the name current source file, which can be different 
than $0 in different modules.

freebie:~ 839> ruby aprog.rb
$0: aprog.rb
__FILE__: ./amodule.rb
aprog $0: aprog.rb
aprog __FILE__: aprog.rb
freebie:~ 840> cat aprog.rb
#!/usr/local/bin/ruby
require 'amodule'

f = Foo.new

f.pr_dollar0
f.pr_file

puts "aprog $0: #{$0}"
puts "aprog __FILE__: #{__FILE__}"

exit 0

__END__
freebie:~ 841> cat amodule.rb
class Foo
  def pr_file
    puts "__FILE__: #{__FILE__}"
  end
  def pr_dollar0
    puts "$0: #{$0}"
  end
end

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