in reply to for, foreach and $_...
should probably read:foreach (0..@array)
as you want to access all of the current elements of the array, rather than add an extra one at the end (@array in scalar context is the number of element, whereas $#array is the ordinal number of the last element). And since arrays are (usually) 0-based, the highest numbered element is one less than the number of elements.foreach (0..$#array)
If you do:
then $_ is aliased to the array element being processed. So everything you do to $_, you are actually doing to the array element.foreach (@array)
Hope this helps.
Liz
|
|---|