On Thu, Jul 10, 2003 at 02:50:21PM +0900, Daniel Carrera wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > On Thu, Jul 10, 2003 at 02:47:16PM +0900, Mauricio FernáÏdez wrote: > > > What about > > > > require 'English' > > re = ARGV.shift > > $DEFAULT_INPUT.each{|x| puts x if x =~ /#{re}/} > > > > ?? > > > > It's two lines if you use '$<'... > > Did you see mine? It was one line! (with a semicolon though :) They're the same if you omit the fact that I forgot about Enumerable#grep ;) It turns out that $<, $DEFAULT_INPUT _and_ ARGF are synonyms. IMHO one semicolon is equivalent to one line-break but we can still make it a one-liner without cheating: re = ARGV.shift and puts ARGF.grep(/#{re}/) However, I don't quite like this example, it feels perlish. I'd rather show singleton methods at work, or blocks, or metaclasses... -- _ _ | |__ __ _| |_ ___ _ __ ___ __ _ _ __ | '_ \ / _` | __/ __| '_ ` _ \ / _` | '_ \ | |_) | (_| | |_\__ \ | | | | | (_| | | | | |_.__/ \__,_|\__|___/_| |_| |_|\__,_|_| |_| Running Debian GNU/Linux Sid (unstable) batsman dot geo at yahoo dot com Problem solving under Linux has never been the circus that it is under AIX. -- Pete Ehlke in comp.unix.aix