From: anon1m0us Date: 2007-02-07T04:15:14+09:00 Subject: undefined method `empty?' for nil:NilClass (NoMethodError) Hi; I have a script that goes through a file to match information and puts them in different arrays. When I run the program I receive in the following error: undefined method `empty?' for nil:NilClass (NoMethodError). My code is: Cemployee=Array.new CemployeeID=Array.new CemployeeName=Array.new CemployeeGroup=Array.new CMachineGroup=Array.new CMachineShares=Array.new CShareAccess=Array.new counter=0 excelcounter1=2 excelcounter2=2 excelcounter3=2 excelcounter4=2 File.open("D:\\Reports.txt").each { |lineinfo| user=lineinfo group=lineinfo machine=lineinfo shares=lineinfo access=lineinfo m = /^([C]\d+)\s(\w+.+)/.match(user) n= /^\b(Groups:)\s.+/.match(group) o= /^\b(Machine Group:)\s(\w+.)*/.match(machine) p=/^\b(Share Name)\s.*/.match(shares) q=/^\b(Access Level)\s.*/.match(access) if m CemployeeID[counter],CemployeeName[counter]=user.split(" ") counter+=1 excelcounter1+=1 elsif p junk,CMachineShares[counter]=group.split(": ") CMachineShares[counter].empty? CMachineShares[counter].slice!("\n") puts CMachineShares[counter] puts CMachineShares[counter] #$excel.Worksheets(2).Range("A#{excelcounter4}") ['Value']=CMachineShares[counter] #excel.Worksheets(2).Columns.AutoFit #counter+=1 end }