From: Charles Steinman Date: 2005-08-11T05:01:10+09:00 Subject: Re: anonym variable $_ and foreach similar in Ruby ? ngoc wrote: > Hi > In perl > print $_, "\n" foreach (@array); > In Ruby > array.each { |e| print e, "\n" } > or > array.each do |e| print e, "\n" end > > So |e| is similar to $_. But I can not > say > { |e| print e, "\n"} array.each > > because of block as argument and OO issue. In addition, it looks a > little bit complicated in Ruby. I think in THIS CASE perl is more > elegant than Ruby? > > Is it a right thinking (IN THIS CASE)? > Are there other ways than those two array.each? There is also ----code--- for e in array; puts e end ----endcode--- But more logical for this purpose, I think, is ----code--- puts array ----endcode---