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>){ ... } #### my @list = map {$_ => 1} @other_list; my @filtered_list = grep {$_ =~ /blah/} @some_list;