suppose i have the following piece of code to read some data (input by
the user) following END
while line = DATA.gets
one_record = line.chomp!.split
bought 2 widgets 17.99
sold 12 widgets 22.49
bought 11 things 12.99
sold 5 things 10.49
as you can see, there is a blank line ahead of the first line of data (i
don’t want that), and there may be one or more blank lines or lines
containing spaces after the data or even between the lines of data.
i can’t control what the user will do here, but i need to take it into
account. any suggestions on how to ensure that any line i read contains
the 4 desired fields and doesn’t contain anything else (even 4 blank
spaces like between the last bought and sold records)?