From: Adam Penny Date: 2008-10-21T07:36:36+09:00 Subject: Can anyone tell me why my code isn't working? Hi there, For some reason the get_mac_by_printer(host_name) method isn't working. All the other bits work, but I have a feeling that I'm running into a problem with variables defined within blocks, but I'm at a loss as to how to negotiate it. The resulting mac is returning as nilClass and it definitely isn't nil! Code as follows: #Class for handling the plist file. class PlistHash def initialize(path) @path=path @plist_hash=Plist::parse_xml(@path) end def get_mac_by_host(host_name) servers=@plist_hash['servers'].each do |s| mac=s['mac'] if s['name']==host_name return mac end end def get_mac_by_printer(printer_name) printers=@plist_hash['printers'] printers.each do |v| host=v['host'] if v['name']==printer_name return host end mac=get_mac_by_host(host) return mac end def get_broadcast_ip broadcast_ip=@plist_hash['broadcastIP'] end end Thanks for your help, Adam -- Posted via http://www.ruby-forum.com/.