Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
perlでgrepを使いたいのですが、ここで混乱しています。私がやりたいのは、次のようなファイルが1つあります-
this is abctemp1 this is temp2 this is temp3x this is abctemp1
ここで、パターン 'temp' を使用してこのファイルから一意の単語、つまり 'abctemp1, temp2, temp3x' を抽出し、それを配列に格納したいと考えています。これを行う方法?
use strict; use warnings; my (@array, %seen); /(\w*temp\w*)/ && !$seen{$1}++ && push @array, $1 while <DATA>; print "$_\n" for @array; __DATA__ this is abctemp1 this is temp2 this is temp3x this is abctemp1