ファイルを解析しています。最初に行うことは、最初の 3 つのフィールドを連結し、それらを各レコードの先頭に追加することです。次に、コロン、一重引用符、二重引用符、またはバックスラッシュのデータをスクラブしたいと思います。以下は私がやっている方法ですが、より効率的な $line 変数を使用してそれを行う方法はありますか?
# Read the lines one by one.
while($line = <$FH>) {
# split the fields, concatenate the first three fields,
# and add it to the beginning of each line in the file
chomp($line);
my @fields = split(/,/, $line);
unshift @fields, join '_', @fields[0..2];
# Scrub data of characters that cause scripting problems down the line.
$_ =~ s/:/ /g for @fields[0..39];
$_ =~ s/\'/ /g for @fields[0..39];
$_ =~ s/"/ /g for @fields[0..39];
$_ =~ s/\\/ /g for @fields[0..39];