read IN, my $html, -s $file; # your code my $file = do{ local $/; }; # The way I usually use.