in reply to how to repeat a if else statement in a nested for loop

You really need to try harder to explain it, because so far, you seem to be contradicting yourself. First you say that you're "trying ... to get numbers that don't match", and then you say "I need it to do this" and you give sample output where it makes no difference whether the numbers match or not. So which is it?

You might be getting confused by your poor use of indentation, and your irregular use of line breaks vs. spaces between statements. Here's how the nested "for" loops in the OP script look when formatted in the "normal" Perlish way (and with a normal use of "print"):

for ( $a = 0; $a <= $i; $a++ ) { for ( $s = 0; $s <= $i; $s++ ) { my $d = 0; print "$a\t$s\n"; if ( $a != $s ) { print "Yes.->$a$s\n"; last; } print "system command \$a $a, then for \$s $s".$n; $d++; } }
Having "last" inside the "if" block means that as soon as $a and $s have different values, you go directly to the next value of $a. When $a is 0, you get two iterations on $s, but after that (with $a > 0) you exit the inner loop immediately (because $s always start at 0, which is always different from $a), so you never reach the "system command" print statement.

Proper indentation is important, especially when you're already confused about other things.