From: David Alan Black Date: 2001-08-09T21:49:44+09:00 Subject: [ruby-talk:19424] Re: Setting $_ for the current scope Hello -- On Thu, 9 Aug 2001, Dave Thomas wrote: > Renald Buter writes: > > > Looking back at my question, I see it is a bit fuzzy. What I am > > really looking for is a case-like structure _with_ fall-through, but > > _without_ having to write down the variable name for each regexp > > test. > > Possibly the Ruby case statement might help :) > > case bla > when /help/ then help > when /exit/ then exit > else > puts "Sorry" > end > > And not a $_ in sight. I think Renald wanted the possibility of more than one statement executing. In his Perl-esque example: > bla = "help_more" > for bla > # $_ is now equal to bla ("help_more") > /help/ and help > /help_more/ and help_more > /help_even_more/ and help_even_more > end help and help_more would both happen. One possibility would be: for $_ in bla help if /help/ help_more if /help_more/ help_even_more if /help_even_more/ end I've gotten so unused to seeing $_ :-) Any chance that some other form of method dispatch would be cleaner/safer? (But that's another matter.) David -- David Alan Black home: dblack@candle.superlink.net work: blackdav@shu.edu Web: http://pirate.shu.edu/~blackdav