From: Martin DeMello Date: 2003-09-22T00:47:19+09:00 Subject: Re: RCR: New interpreter switch Gavin Sinclair wrote: > On Sunday, September 21, 2003, 11:46:33 PM, Martin wrote: > >> One place where perl's heavy use of implicit variables scores is in >> quick one-liners from the command prompt. I think ruby would be more >> appealing in that area if it had a switch that ran the following loop: > >> while gets >> print $_.instance_eval { >> ... >> } >> end > >> This would generalise the existing technique of mixing a few String >> methods like gsub and scan into Kernel and having them act implicitly on >> $_. > > > An alternative would be to create a file that adds all the methods you > want to Kernel, and require that on the command line. Just a thought. I thought of that - it doesn't work because in several cases you're still left with having to assign the result to $_ or call print/puts explicitly. A method that will work is to wrap a shell script around ruby, that puts the loop and the instance_eval in for you. But it'd be nicer to see it as a switch. martin