my $fh = IO::File->($datafile) or die; #instead of - and you don't need the quotes either my $fh = new IO::File "$datafile"; #### while (<$fh>) { chomp; # use $_ instead of $row # etc . . .