我有一個這樣的文件:如何分割每個空白的數組的每個條目?
This is is my "test"
file with a lot
words separeted by whitespace.
現在我想達到這樣我創建一個數組,其中每個元素都包含一個字,所有重複的單詞被刪除
所需陣列拆分此:
This
is
my
test
etc...
我將文件讀入數組,但我不知道如何拆分整個數組,以便結果是一個新的數組。我怎樣才能刪除重複的單詞?
#!/usr/bin/perl
package catalogs;
use Log::Log4perl;
Log::Log4perl->init("log4perl.properties");
open(FILE, "<Source.txt") || die "file Sources.txt konnte nicht geoeffnet werden";
my @fileContent = <FILE>;
close FILE;
my $log = Log::Log4perl->get_logger("catalogs");
@fileContent = split(" ");
你能解釋一下你提取方法嗎?什麼是$ str?我已經將文件讀入數組名稱@fileContent,是不是指這個數組而不是$ str? – 2013-03-06 23:49:08
您想從中提取單詞的字符串。數組不包含單詞。 – ikegami 2013-03-06 23:54:26
...如果您想要搜索數組中的所有字符串,請執行此操作。或者不要首先使用你不需要的數組。 – ikegami 2013-03-07 04:43:08