my $size = 2000; # or whatever open( FH, "sample.txt") or die("Error: $!\n"); read( FH, $data, $size ); close FH;