On Mon, Apr 16, 2007 at 03:06:58AM +0900, Chad Perrin wrote: > Over the years, I've found the following to be an excellent way to whip > up quick, very useful Perl scripts: > > #!/usr/bin/perl > > while(<>) { > # do stuff . . . > } > > Is there an equivalent idiom in Ruby? So far as I'm aware, there's no > catch-all diamond operator in Ruby that allows one to create a default > input behavior for a script that accepts either a filename or piped > output of another command the way this works in Perl. I certainly hope > there's an equivalent, though. while gets # do stuff with $_ end Or, less perly, while line = gets # do stuff with line end Or, if there are multiple files listed on ARGV, and you want to slurp them all one at a time, while contents = gets(nil) # do stuff with contents end Doing that in Perl seems quite hard. B.