Finding All Children Between Two Selections

He guys-

I was wondering how to return all children of a node, but stop when I got to the second selection... for instance... say I have a hip joint, and an akle joint selected... how can I return both of these joints and the joints between them, but stop when I reach the ankle joint?... here is some psuedo code

CODE
$sel= ls -sl -fl;

$sel1 = $sel[0];
$sel2 = #sel[1];

string $desiredChildren[];

for ($y = 0; $y < 100 (arbitrary); $y++){

        if ( $child[$y] != $selSize -1{

                 $desiredChildren[$y] = $child[$y];

$y++;
}
}

I know it's sloppy, but I am just looking to tell the loop to stop when it reaches my second selection.... any ideas... thanks

Sheriff

network solutons

use while loop: you could use break but its better to while because peopl eexpect it to terminate. Making it easier to read understand and debug