in reply to foreach in array

The "problem" here is that the diamond operator consumes one line of input. So the line

while (<JOE>) {

eats the first line of the input file, but doesn't save it anywhere. You either want just

my @data = <JOE>;

or

my @data; while (<JOE>) { push @data, $_; }

and yes, yes, yes, always

use strict; use warnings;