Good point. Since "computer golf" is so much fun, here's my
solution in Ruby (I tried the awkish approach, but this is
shorter):
ruby -e 'p ARGF.map{|x|x.size}.max-1' somefile.txt
Is ARGF an array of lines of the files supplied on the command line
in a similar way to Perl's <> handle?
Doesn't Ruby's map method have the equivalent of Perl's anonymous
scalar? In Perl you might write:
@line_lengths = map length, <>;
without having to name a variable x *twice* as in your example.
So, just hand waving here, Ruby might write: AGRF.map{.size}
or similar.
PS. Is there any great motivation for your Ruby advocacy when we'll
all someday be sharing the Parrot runtime anyway? Seems to me the
main motivation for advocacy of one language over another would be
because you want more people to contribute to your favourite language's
codebase in the same way that Perl gains so much from CPAN contributions.
With Parrot, the language war is over because everyone's contributions
will work together regardless of the language they're written in.
So, I can't help feeling your efforts would be better directed in
the comp.lang.ruby group, rather than here. Ruby has too much in
common with Perl for it to be worthwhile any of us learning it if
we're already happy with Perl and, until Parrot is widely available,
CPAN tips the usefulness in favour of Perl anyway. Sure, you've shown
us that Ruby is cute, expressive, and powerful, but that's just
not enough for most people.