# function sub do_thing { my ($name, $country) = @_; print "Person's name: $name, country: $country\n"; } # file { # file handle is scoped to this block open my $fh, '<', 'file.txt' or die $!; while (my $line = <$fh>){ # we're now in a lower-level scope print "$line\n"; } } # file handle is closed and unavailable here