From: Robert Keller Date: 2007-10-27T07:27:45+09:00 Subject: improperly exiting loop with DATA and __END__ --0-345956240-1193437666=:2445 Content-Type: text/plain; charset=us-ascii I have this bit of code that loops through the __END__ data and does some time sheet processing. All that bit works, but when I get to the end of the "DATA" I get an error about calling split for a nil:NilClass...I an sure it is because I am trying to process the last record which is an empty string. I've been googling and looking at the book for hours, but can not get this bit right. How do I trap the empty string and exit the loop properly. Thanks in advance for any help! Friday -- Morning hours 4.75 Afternoon 5.23 total 9.98 hour_calu.rb:12: private method `split' called for nil:NilClass (NoMethodError) >Exit code: 1 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> while times = DATA.gets.chomp.split(",") day_of_week = times[0].split(",") ##bunch of other rubish calculations go here printf(" %8s -- Morning hours %01.2f day_of_week, morning_e_time) week_total =+ morning_e_time + afternoon_e_time end puts ##printf("Weekly total %01.2f\n",week_total) __END__ Monday,07:46,12:04,12:45,17:09 Tuesday,08:00,12:28,13:21,18:09 Wednesday,07:49,12:05,12:58,18:01 Friday -- Morning hours 4.75 Afternnon 5.23 total 9.98 hour_calu.rb:12: private method `split' called for nil:NilClass (NoMethodError) >Exit code: 1 ------------------------------ Robert Keller rlkeller@yahoo.com --0-345956240-1193437666=:2445--