#!/usr/bin/perl -w use strict; my @a1 = qw(My name is Andrew); my @a2 = qw(My dog named Andrew); my $i; my $a = 0; my $s = 0; my $z = 0; my $aa; my $ss; my $n = "\n"; my $t = "\t"; foreach my $a1 (@a1){ $i++; #print $a1 . "\n"; } First:for($a = 0; $a <= $i; $a++){ Second:for($s = 0; $s <= $i; $s++){ my $d = 0; print $a.$t; print $s.$n; if($a!=$s){ print "Yes.->".$a.$s.$n; last} print "system command \$a $a, then for \$s $s".$n; $d++; } } #### 0 0 system command $a 0, then for $s 0 0 1 Yes.->01 1 0 Yes.->10 2 0 Yes.->20 3 0 Yes.->30 4 0 Yes.->40 #### system command $a 0, then for $s 0 system command $a 0, then for $s 1 system command $a 0, then for $s 2 system command $a 0, then for $s 3 system command $a 0, then for $s 4 system command $a 1, then for $s 0 system command $a 1, then for $s 1 system command $a 1, then for $s 2 .... and so on and so on.