------art_31512_28639125.1149107598969
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

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 !! :)

def splitpipe( string )
  count  
  record  tring.split('|')
  record.each do |element|
    element  lement.strip
    element  ormatnum(element) if element /\d?\.\d+/
    element  onvertdate(element) if element /^\d\d\/\d\d\/\d\d$/
    record[ count ]  lement
    count + 
  end
end

def formatnum(num)
  num  um.to_f
end

def convertdate(date,type
  datearray  ate.split('/')
  if datearray[2].to_i > 90
    datearray[2]  19" + datearray[2]
  else
    datearray[2]  20" + datearray[2]
  end
  if type 'human'
    date  atearray.join("-")
  elsif type 'array'
    datearray
  else
    date  atearray[2] + datearray[0] + datearray[1]
  end
end

salesfile  ile.new( FILENAME, 'r' )
worksign  
objects  rray.new
salesfile.each_line do |line|
  record  plitpipe( line.gsub(/^H:/,'') )

  if record[1] 'C' or record[2] 'Y'
    worksign  1
    record[9]  ecord[10] if record[1] 'C' #Set qty shipped if credit
work around
  else
    worksign  
  end
  record[6]  ecord[6] * worksign
  record[7]  ecord[7] * worksign
  record[9]  ecord[9] * worksign
  record.each { |e| puts e }
  exit
end
salesfile.close

------art_31512_28639125.1149107598969--