my $filecontents; if ( open( FILE, "whatever" )) { local $/; # this sets $/ locally to undef within this block $filecontents = ; close FILE; } else { die "whatever: $!"; } # all data from "whatever" is now contained in $filecontents # and $/ is now back to its previous value