# variables to use my $i,$input='r',$done; # start $input off as r, so the empty array comes up first my @array=(0,0,0,0,0,0,0,0); print "Press q to quit, r to reset, anything else to increase the count\n"; while ($input ne 'q') { if ($input eq 'r') { # reset the array @array=(0,0,0,0,0,0,0,0); } else { while($done == 0) { if ($array[$i] == 1) { $array[$i] = 0; $i++; } else { $array[$i] = 1; $done = 1; } } $i=0; # reset the array counter $done=0; # reset the done flag } print "\t$array[7] $array[6] $array[5] $array[4] $array[3] $array[2] $array[1] $array[0]\n"; chomp($input = ); # chomp takes off the carriage return on the input line }