As others have pointed out you are not running under use strict and use warnings, and you are not checking the return status of your system calls. For the latter you should at least have something like

system("dsspcmbi $pdbstructure $dsspfile") and die "System called fail +ed.";
to alert you that something went awry, and where. (Note that system is the unusual Perl function that returns a true value upon failure, hence the and clause to check for failure.)

Next, the line

$residuecombofile = "$combodir$residue1$residue2$residue3$out";
is executed redundantly at a couple of places throughout the program (as far as I can tell, the RHS always evaluates to the same value); moreover, $residue1, $residue2, and $residue3 are undefined. (BTW, on the naming of variables, you may want to read this node.) In your post you refer to "OUTFILE's" but it is clear that this program will generate at most one OUTFILE, whose name is the constant value of $residuecombofile.

You open a file handle PDB with this line

if(open(PDB,"$pdbstructure"))
but you don't do anything with the handle. If all you want to do is check for the existence of this file, use
if ( -e $pdbstructure )
or better yet
if ( -r $pdbstructure )
(See file test operators). Furthermore, if the open cited above fails once, then it sets $flag, which would stay set, since it is never reset back to 0 anywhere (in fact, this variable is never properly initialized outside of the loop); this means that, after one failure of the open, the then clause of the if statement beginning with
if($flag == 0)
would never again be executed, even if subsequent calls calls to open(PDB,"$pdbstructure") structure succeed. (BTW, the idiomatic way to make the test above is unless ( $flag ).) Do you ever see the message
No structure file. Moving to next structure in list
?

the lowliest monk


In reply to Re: misbehaving program by tlm
in thread misbehaving program by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.