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.
my $line = "file1.gz file2.gz file3.gz"; my @abc = split('', $line); print "@abc\n";
期待される出力:
file1.gz file2.gz file3.gz
出力をfile1.gzin $abc[0]、file2.gzin $abc[1]、および file3.gzin にしたい$abc[2]。分割方法を教えてください$line。
file1.gz
$abc[0]
file2.gz
$abc[1]
file3.gz
$abc[2]
$line
/\s+/ を '' に対してスプリッターとして使用するだけです。この場合、すべての「余分な」空白が削除されました。通常、この特定の動作が必要です。したがって、あなたの場合は次のようになります。
my $line = "file1.gz file1.gz file3.gz"; my @abc = split(/\s+/, $line);