From: Frank Mitchell Date: 2001-10-20T16:06:51+09:00 Subject: [ruby-talk:22817] Re: PLease condense my code Joseph McDonald wrote: > > FM>> do_print = true > FM>> ($<).each_line { |line| > FM>> case line > FM>> when /=begin/ then > FM>> do_print = false > FM>> when /=end/ then > FM>> do_print = true > FM>> when /=[-a-zA-Z0-9. ]*=/ then > FM>> # do nothing > FM>> else > FM>> if do_print then > FM>> puts line > FM>> end > FM>> end > FM>> } > Actually, does this one not work: > > while gets > print if (!(/=begin/../=end/) && !(/^=[-a-zA-Z0-9. ]*=/)) > end > > It is basically a copy of the perl version. Weird. I thought I tried something like that; I recall the Range seemed to get stuck after the "=begin". It might have been a logic error ... plus I keep forgetting that Ruby uses Perlish global variables and default arguments. Anyway, that suits my rhetorical purposes very well. Thanks. -- Frank Mitchell (frankm@bayarea.net) "What is luck? Luck is probability taken personally. Luck is the excitement of bad math." -- Penn Jillette