in reply to Re^2: While.For loop noob query
in thread While.For loop noob query

$#lines is the index of the last elements of the array @lines. Let's say you have 10 lines. Their indexes would be 0 through 9, so $#lines would be 9.

@lines[ LIST ] is an array slice. It returns a list formed from the elements indexed by LIST. In our earlier example, @lines[0..($#lines - 1)] returns elements 0 through 8.

The for here starts a foreach loop over each element of the returned list. In other words, it loops over all up the last element of @lines. Since no variable name is specified, $_ will hold the value for the current iteration.

I think $#array and array slices are documented in perldata. Loops are documented in perlsyn.