F1.txt
tom
x
a=1 b=2 c=3 d=4 e=5
y
b=11 r=12
bob
a=6 b=7 c=8 e=10
結果
F2.txt
. X Y
name a b c d e b r
tom 1 2 3 4 5 11 12
bob 6 7 8 - 10 - -
私のこの問題で親切に助けてもらえますか?ファイル F1.txt があります。私の仕事は、そのファイルを例 F2.txt に示すような形式に変換することです。F1.txt の数値を除いて、Tom と Bob の後のすべての文字列値を削除してから、連結してみました。コードは次のとおりです。
use strict;
open (file100,"< data.txt");
open (file101,">>F3.txt");
my @array = < file100>;
print file101 "name a b c d e\n\n";
print file101 "tom @array[1]\n\n";
print file101 "bob @array[3]\n\n";
ここにdata.txt:
tom
1 2 3 4 5
bob
6 7 8 10
このコードで得られる出力は次のとおりです。
F3.txt
name a b c d e
tom 1 2 3 4 5
bob 6 7 8 10
予想される出力は、F2.txt に示されているようになるはずですが、F3.txt とは異なります。