in reply to if conditional in nested for loop

With what you've provided, no. See How (Not) To Ask A Question. Specifically, without knowing what is in your arrays (@beginning, @ending, @interdomainatoms) there is no way replicate your code's behavior.

As a stylistic note which has nothing to do with your present query, using foreach loops in place of C-style for loops will make your code less prone to typographical bugs, e.g.

my $counter = 1; foreach my $iseg (1 .. $nseg){ foreach my $ires ($beginning[$iseg] .. $ending[$iseg]) { if ($ires == $interdomainatoms[$counter]) { print STDOUT $interdomainatoms[$counter]; $counter++; } } }

See For Loops for details.