my $file = 'sample.txt'; my $buf; { local *FH; open FH, "$file" or die $!; -f FH and sysread FH, $buf, -s FH; }