From: Garance A Drosehn Date: 2006-09-01T11:39:43+09:00 Subject: Rescuing a 'require' I wanted to use Socket.gethostname to get the current hostname without executing a unix command. So: require 'socket' $this_host = Socket.gethostname I have to run this code on several platforms, and it turned out that some of them do not have 'socket'. So, my first idea was change it to: begin require 'socket' $this_host = Socket.gethostname rescue $this_host = `hostname`.chomp end but the require still caused the script to terminate on the platforms which didn't have 'socket'. I already have an alternate solution for this specific case, but I'm wondering if there was something that I missed. Is there any way to catch errors from a require command? -- Garance Alistair Drosehn = drosihn@gmail.com Senior Systems Programmer Rensselaer Polytechnic Institute; Troy, NY; USA