#!/usr/bin/perl

open(IN, "phy.dat") or die "Can't read file\n";
@filearray = <IN>;
$num=@filearray;
print "Processing data...\n";
print "There are $num lines in this file.\n";
$fsum=0;
$fdes=0;

for($i=0;$i<$num;$i++){
$_=$filearray[$i];
s/\n//g;
s/\\n/ /g;
s/\\\;/\;/g;
s/\\\,/\,/g;#dumps format specific stuff
s/SUMMARY/Summary /g;
s/DESCRIPTION/Description /;
s/\s+/ /g;#dumps extra white space
#s/^\s+//;#dumps leading white space
s/\s+$//;#dumps trailing white space
$filearray[$i]=$_;
@col = split(/:/, $filearray[$i]);
$numc=@col;
if ($col[0] eq "Summary "){$fsum=1;$fdes=0;print"\n";}
if ($col[0] eq "Description ") {$fdes=1;}
if ($col[0] eq "CLASS") {$fsum=0;print"\n";}
if($fdes==1){for($j=0;$j<$numc; $j++){
#    print "$col[$j]";
    @white=split(/ /,$col[$j]);
    $numw=@white;
    $k=0;
    while($k<$numw){
    $kold=$k;
    if($white[$k] eq "Description"){print"";$k++;}
    if($white[$k] eq "Host"){print"\n$white[$k]\n";$k++;}
    if($white[$k] eq "Title"){print"\n$white[$k]\n";$k++;}
    if($white[$k] eq "Abstract"){print"\n$white[$k]\n";$k++;}
    if($white[$k] eq "Speaker"){print"\n$white[$k]\n";$k++;}
    if($white[$k] eq "Location"){print"\n";$k++;}
    if($white[$k] eq "Time"){print"\n";$k++;}
    if($white[$k] eq "Disque"){print"\n";$k++;}
    if($white[$k] eq "919"){print"\n";$k++;}
    if($k==$kold){print"$white[$k] ";$k++;}}
}}
}
