Im new to perl and i want a perl script to convert each coordinate file of different proteins(decoys) to pdb file format.this is the script i wrote so far.

open (f1, "rep.tra1");
while ($line = <f1>)
{
chomp $line ;
@det+split (" ", $line );
$num= @det;
if ($num = = 4)
{
$decoy=$det[0];
$count= 0 ;
}
else
{
$count++
$ X[$decoy] [$count]= $det[0];
}
}
print "$ X[1][1] \n";

exit;

for ($i=1;$i<=80; $i++)
{
$outfile= "decoy" $i ".pdb" ;

}
close() ;
}

Please attach data from your rep.tra1 file to your post so somebody can test your script.

In what way does the output of your script not meet your expectations?