in reply to infinite loop on while (@array)
Does anyone know if while loops could be used like this while (@array){};
That's possible, and will repeat the block while @array is true. @array in scalar context returns the number of elements, so this will loop while @array has elements. If you don't remove elements from it, it wil loop indefinitely.
With Perl, you can create any loop you want. There's a number of useful loop forms already: while, do while, do until, and two kinds of for(each). If that's not sufficient for whatever you want (you didn't really describe what you want), you can create any loop yourself. Bare blocks are considered loops, but they are executed only once if you don't change that yourself. You can use redo and last together with if and unless to construct your very own, very specific loop.
U28geW91IGNhbiBhbGwgcm90MTMgY
W5kIHBhY2soKS4gQnV0IGRvIHlvdS
ByZWNvZ25pc2UgQmFzZTY0IHdoZW4
geW91IHNlZSBpdD8gIC0tIEp1ZXJk
|
|---|