I have a string of data that I am trying to pull values from and have
hit a roadblack since I am still getting the hang of Ruby, in Perl this
would be easier but it seems that Ruby may be able to do this much
simpler.

My data starts as -
  send data StartTime: 20090413 13:41:53.000 ScriptName:changeTests
Pass:15 Fail:0 Total:15

Then I am able to regex it to something like -
  ScriptName:changeTests Pass:15 Fail:0 Total:15

The code I have is:
        if line =~ /data/
            # Remove everything from the beginning up to ScriptName
            line.sub!(/^send.*\d\d\d\s/,"")
            # Split the line by space, then get pairs by :
            arr = line.split(/\s/).map do |i|
                t = i.sub(/[a-zA-Z]+\:([a-zA-Z]+|\d{2,3})/)
            end
        end

After the arr = line.split I am not sure what to do, I was playing
around with various ways of pulling the data out but I am not totally
clear on Ruby data structures.  What I would like to do is pull out all
the values to the right of the :'s and save them for a SQL insert
statement, this is data I would like to store in a database after
pulling out the values I need.  Is it easier to use map to be able to
iterate through the values, or can I actually split the data line so
that I can end up with each combined value sort of acting like a hash
key?  I'd appreciate some hints on what might be a good next step so
that after arr I should be able to have values like:
ScriptName = changeTests
Pass = 15
Fail = 0
Total = 15

Thanks
-- 
Posted via http://www.ruby-forum.com/.