Hi --

On Sat, 26 Aug 2006, William James wrote:

> Oliver Bandel wrote:
>> Hello,
>>
>>
>> The Code:
>>
>> ====================================
>> def look_for_begin
>>    while line = gets
>>      if line =~ /^begin/
>>        puts line
>>        # return
>>      end
>>    end
>> end
>>
>> ARGF.each { look_for_begin }
>> ====================================
>
> puts ARGV.map{|f|IO.readlines(f).find{|s|s=~/^begin/}}

Or maybe:

   puts ARGF.find {|s| /^begin/.match(s) }


David

-- 
http://www.rubypowerandlight.com => Ruby/Rails training & consultancy
   ----> SEE SPECIAL DEAL FOR RUBY/RAILS USERS GROUPS! <-----
http://dablog.rubypal.com        => D[avid ]A[. ]B[lack's][ Web]log
http://www.manning.com/black     => book, Ruby for Rails
http://www.rubycentral.org       => Ruby Central, Inc.