On Tue, 02 Jul 2002 20:35:13 Paul Duncan wrote: : * Yukihiro Matsumoto (matz / ruby-lang.org) wrote: : > Hi, : > : > In message "grep regex to ruby regex..." : > on 02/07/03, Todd Holloway <todd / duckland.org> writes: : > : > |I'm just about to finish up my first ruby program, but I'm : > |stuck on one last part...I need equivlent of the below in ruby: : > | : > |grep -v "^[[:space:]]*#" filename | grep -v '^[[:space:]]*$' : > : > File.foreach(filename) do |line| : > next if /^\s*#/ =~ line : > next if /^\s*$/ =~ line : > print line : > end : : ruby -lne 'print unless /\s*#/ or !/\S/' filename : : I'm golfing with the champ! : :D Except matz wins because the oringal poster wants it as part of a ruby program _not_ a one liner ruby program :) Regards, Chris -- +------------------------------------------------------------------+ | Chris Ross | chris / darkrock.co.uk | ctr / ferite.org | | | http://www.darkrock.co.uk | http://www.ferite.org | +------------------------------------------------------------------+ "Growing old is mandatory; growing up is optional."