in reply to Re: whats wrong with this code?
in thread whats wrong with this code?

Thanks for the answer. I think Im now close to understanding what happens.

Replies are listed 'Best First'.
Re^3: whats wrong with this code?
by Marshall (Canon) on Jan 18, 2017 at 12:16 UTC
    Glad to hear that this is helping. I was worried about confusing things more.

    A few more comments about the difference between "while" and "foreach"..

    This while loop is testing whether or not there are any elements in @array. That number of elements is the scalar value of the array. The keyword scalar is not needed because in this context it is implied. However, "scalar" can be used. The while loop does not muck with the $_ variable. But the foreach loop does.

    while (scalar @array) #scalar not needed, but this is what is meant { print "@array\n"; shift (@array); }