- or download this
% perl kwic.pl a an the
an ostrich
...
the an BIRD
an OSTRICH
%
- or download this
$i{$x}=1while$x=pop;s/\w+/$i{$&}or$k{$&}.="$`\U$&\E$'"/egwhile<>;print
+@k{sort keys%k}
- or download this
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}