in reply to question on Arrays
You never increment $i, so you never will never reach the code where you compare the number to the array
I could stop the program with ctrl-C without any problems. ctrl-Z would make the program run as a background prozess here on linux, don't know what you have running
Even if you had changed $i you would not get the right results. You use exit to presumably exit the loop, that is done with last. exit exits the program.
Also your logic is wrong. When it compares the first value in the array with the new value and it is different, it already pushes the new value into the array. But you have to wait until you compared the new value to ALL values before you can push it. Ergo you need to wait until after the loop before you can add that new value
Please indent correctly. Your program is very hard to read
Please 'use warnings;'
To find out what is happening in a program, put print statements into it and print out variable values. If you had inserted a print statement just before the loop (to find out what is going on) you would have found out that that part of the code was never executed.
|
|---|