use warnings; use strict; my $thing = 123; { my $thing = 456; } print $thing; # 123 open my $fh, '<', 'file.txt' or die $!; { local $/; # slurp in a file my $contents = <$fh> ... } # now we go back to reading a file line-by-line again while (<$fh>){ ... }