#!/usr/koeki/bin/ruby # coding: euc-jp name = Array.new STDERR.print "検索パターン: " pattern = STDIN.gets.chomp request = Regexp.new(pattern, true, "e") open("station.dat","r") do |candidate| i = 0 while station = candidate.gets if request =~ station # print station if /(\S+)\s+(\S+)\s+(\S+)\s+(\S+)/ =~ station name[i] = $1 printf("%d \t %s駅\n", i+1, name[i]) i += 1 end end end end