Paul D. Kraus schrieb: > Below is a quick attempt at doing some things in ruby that I have been > doing > in perl. > Question 1 how can I save and then reuse the functions that are defined in > other applicaitons. > Question 2 how can I rewrite some this in a more ruby way > > Itterating over an array and then having to have a counter variable to make > "in-place" changes seems a little overkill and I am pretty certian there is > probaly a better way. > > I have a lot of pipe delimented text files that I work with that contain > some standard thing that always get converted. Dates and Numbers to name a > few. > > Thanks for you time !! :) > > [...] this should do the same: ---------------------------------------------------------------------- def splitpipe string string.split('|').map do |element| element.strip! case element when /\d?\.\d+/ then element.to_f when /^\d\d\/\d\d\/\d\d$/ then element.split('/').values_at(2, 0, 1).join else element end end end IO.foreach(FILENAME) do |line| record = splitpipe(line.gsub(/^H:/,'')) if record[1] == 'C' or record[2] == 'Y' record[9] = record[10] if record[1] == 'C' work around record[6] *= -1 record[7] *= -1 record[9] *= -1 end puts record exit end ---------------------------------------------------------------------- As i have no input data i'm not 100% sure, also what does work around do? I would suggest using a struct instead of the 'not so speaking' record[6] etc. cheers Simon