in reply to RE: Re: Weird printing
in thread Weird printing

local will do this for you automatically, if you scope it correctly:
my $cat2; { open(FH, 'data.txt') || die "Some error: $!"; local $/; $cat2 = <FH>; close FH; }
You have to make sure $cat2 is defined outside of the block, though, otherwise it'll go out of scope when you want to use it.