配列に読み取ったテキストドキュメントに保存された行があります。ラインは
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;