問題があります。脳がもう考えたくないので、ただ疲れているだけだと思います。とりあえず。スプレッドシートから収集した複数の文字列があり、各文字列は同じレイアウトで、文字列内の特定の部分を検索しています。ただし、これは簡単な部分です。したがって、文字列は次のようになります。
this is a string from Japan
this is a string from China
this is a string from America
this is a string from China
this is a string from England
this is a string from Japan
これらの文字列はローカルではありませんが、Excel シートから収集するので、最後にある各文字列の場所を見つけるために呼び出します。この場合、このような viariable を取得します。
use Spreadsheet::Read;
my $book = ReadData ("INPUT.xlsx");
my @rows = Spreadsheet::Read::rows ($book->[1]);
my $count;
$count = 0;
my @clause_all;
foreach my $tab(@rows) {
$count ++;
my @row = Spreadsheet::Read::cellrow ($book->[1], $count);
print $row[5]; # $row[5] would be the location like "japan, china, america etc.
}
これは私が苦労している部分ですが、ループは $row[5] を単一の用語として認識しています。重複を削除し、配列を取得してからスローするために、各行の $row[5] を何らかの形で結合する必要があります重複を除外します。私はこれをやってみましたが、各 $row[5] の単数形のために機能しません
my %special = ();
foreach (@my_array)
{
$special{$_} = 1;
}
my @deduped = keys %special;
print "@deduped\n";
ただし、このような独自のテスト配列を作成すると、元の順序からそれらをスローする以外に機能するため、配列に格納された場所 $row[5] を取得する必要があります。
@my_test_array = ("Japan", "China", "America", "China", "England", "Japan")
my %special = ();
foreach (@my_test_array)
{
$special{$_} = 1;
}
my @deduped = keys %special;
print "@deduped\n";
前もって感謝します!
--------------------------------
編集!
--------------------------------
まあ、これはうまくいきましたが、これがどれほどきれいかはわかりません。:)
use Spreadsheet::Read;
my $book = ReadData ("NSA_DB.xlsx");
my @rows = Spreadsheet::Read::rows ($book->[1]);
my $count;
$count = 0;
my @clause_all;
foreach my $tab(@rows) {
$count ++;
my @row = Spreadsheet::Read::cellrow ($book->[1], $count);
push @array, "$row[3]\n";
}
my %special = ();
foreach (@array)
{
$special{$_} = 1;
}
my @deduped = keys %special;
print "@deduped";
再度、感謝します。