|There's more than one way to do things|
Re^5: Counting keys in a hashby Athanasius (Chancellor)
|on Nov 20, 2012 at 14:50 UTC||Need Help??|
The loop will still work if the data is in an array, won't it?
No, the diamond operator <> is special. In the original loop:
one line is read on each iteration, and the loop continues until <DATA> returns undef to signal that the data accessed via the filehandle (DATA in this case) has all been read in.
But if you have your data in an array (presumably one line per element), you need a for loop (also spelled foreach — they’re the same):
which iterates over the array until each element has been processed.
(Note that in both loops, the line/element read in on a single iteration is stored in the special variable $_.)
Hope that helps,
Athanasius <°(((>< contra mundum