From: Adam Penny Date: 2008-10-21T08:39:06+09:00 Subject: Re: Can anyone tell me why my code isn't working? Solved it. I came up with this solution to force the each loops to return a specific value from the array of hashes. Explicitly returning the value of the block each block did the trick. Still don't think I've got the hang of variable scope though. :-( class PlistHash def initialize(path) @plist_hash=Plist::parse_xml(path) end def get_mac_by_host(host_name) servers=@plist_hash['servers'].each do |s| return s['mac'] if s['name']==host_name end end def get_host_by_printer(printer_name) printers=@plist_hash['printers'] printers.each do |v| return v['server'] if v['name']==printer_name end end def get_mac_by_printer(printer_name) host=self.get_host_by_printer(printer_name) return self.get_mac_by_host(host) end def get_broadcast_ip broadcast_ip=@plist_hash['broadcastIP'] end end -- Posted via http://www.ruby-forum.com/.