in reply to Re^2: File reading
in thread File reading

If the data is in an array instead of a file, just change
while (<DATA>) {
to
foreach (@array) {
Everything else can stay the same.