From: Paul Lutus Date: 2006-12-17T08:05:11+09:00 Subject: Re: question about .gsub Jochen Kaechelin wrote: > line = `tree /Users/aragon/Documents -d` > line.each { |l| > l = l.gsub(/\|/,' ') > l = l.gsub(/\-/,' ') > l = l.gsub(/\`/,' ') > > line = l > puts line > } > > > I use the gsub commands because the tree command produces the > following output: > > |-- DUMMY > |-- lesen.rb > |-- test.txt > |-- test1.rb > |-- test2.rb > `-- tree.rb Seems a shame to strip off all that tree-like formatting and characters, created with so much effort. > Is there a way to reduce the code? puts l.gsub!(%r{[`\-\|]},' '} Not tested. By the way, what are you trying to create? There are better ways to produce a tree display within Ruby itself. -- Paul Lutus http://www.arachnoid.com