From: Carlos Hernandez Date: 2008-01-10T04:17:28+09:00 Subject: Re: Marshal Pipe class MarshalPipe def self.puts(data) Marshal.dump(data,$stdout) end def self.each data = nil begin while data = Marshal.load($stdin) do yield data end rescue EOFError # rudely ignore end end end I guess a class/module above is as clean and simple I can get it. A mp2mp type pipe would be.. require 'marshal_pipe' MarshalPipe.each { |data| transformed_data = transform( data ) # <= do something MarshalPipe.puts transformed_data } A quick csv2mp could be... require 'MarshalPipe.rb' require 'csv' $stdin.each { |line| data = [] CSV.parse_line( line.strip ).each {|item| case item when /^-?\d+(\.\d+)?$/ data.push( ($1)? item.to_f: item.to_i ) # maybe add date handling or any other data type... else # simple string data.push( item ) end } MarshalPipe.puts data } and a mp2txt require 'MarshalPipe.rb' MarshalPipe.each { |data| puts data.join("\t") } A hastily written csv2mp needs cat (not knowing how to read files)... cat source.csv | csv2mp | mp2mp | mp2txt > result.txt But one could argue to make MarshalPipe a template to make pipes in general. That'd be more like I'm actually using, except without the much nicer MashalPipe.(puts and each), -- Posted via http://www.ruby-forum.com/.