我有一行保存在我读入数组的文本文档中。这条线是
John is the uncle of Sam
我有另一个包含单词aunt
和uncle
的数组father
。我希望两个数组都比较和输出叔叔(不区分大小写)。我不知道我做错了什么。我使用List::Compare,Array::Utils qw(:all)等。有人可以给我一个工作代码。我只需要比较部分。
这就是我到目前为止所做的一切。
#!/usr/bin/env perl
use strict;
use warnings;
use Array::Utils qw':all';
print "Please enter the name of the file\n";
my $c = <STDIN>;
chomp($c);
open(NEW,$c) or die "The file cannot be opened";
my @d = <NEW>;
my @g = qw'aunt uncle father';
chomp(@g);
chomp(@d);
my @isect = intersect(@g, @d);
print @isect;