From: Jochen Kaechelin Date: 2006-12-17T08:18:38+09:00 Subject: Re: question about .gsub Paul Lutus schrieb: > 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. I want them to be store in a mysql-database. >> 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. I want to build a dropdown-menu so the admin ca select the homedirectory of an ftpuser. Could you please point me to a better solution? Thanx -- Jochen