% perl kwic.pl a an the an ostrich a big bird the an bird ^D a BIG bird a big BIRD the an BIRD an OSTRICH % #### $i{$x}=1while$x=pop;s/\w+/$i{$&}or$k{$&}.="$`\U$&\E$'"/egwhile<>;print@k{sort keys%k} #### p={} i={} ARGV.each{|x|i[x]=1}.clear while l=gets;l.gsub(/\S+/){|s|p[s]=''if !p[s];p[s]<<$`+$&.upcase+$'if !i[s]}end p.sort.each{|x,y|print y}