Hi all,

I'm probably late to the game on this, but I stumbled across an
interesting use for DATA. You can use it to ensure only one instance
of a given script is running by using flock:

class Foo
   def self.mainloop
      while true
         puts "Looping..."
         sleep 3
      end
   end
end

DATA.flock(File::LOCK_EX)

if $0 == __FILE__
   Foo.mainloop
end

__END_

The first run will work, but trying to start the program up again will
fail instantly because of the lock on DATA. I should probably do some
cleanup there, too, but I thought I'd toss this out there and see if
this is of interest to anyone.

Or was I was recovering from a hangover in college when they mentioned
this trick in class? Anyway, there you go.

Regards,

Dan