大家好,小弟的程式碼是這樣
先開檔讀檔
while (<FILEIN>){
if ($_ =~ /name (\S+) /)
{
$name=$1;
push @name_array, $name;
}
if ($_ =~ /spec (\S+) (\S+) (\S+)/)
{
push @spec_array, $1, $2, $3;
}
if ($_ =~ /spec (\S+)/)
{
push @spec_array, $1;
}
}
close (FILEIN);
for ($i=0;$i<=$#name_array;$i++){
print "name : @all_name[$i]\n";
for ($j=0;$j<=$#spec_array;$j++)
{
print "spec : @spec_array[$j]\n";
}}