http://qs1969.pair.com?node_id=11135939


in reply to Not sure how to handle this scope

Something like this? (simplified...)

#!/usr/bin/perl use strict; use warnings; my $self = 'cat'; print "outside $self\n"; { my $self = $self; print " inside $self\n"; $self = 'dog' if not defined $ARGV[0]; print " inside $self\n"; } print "outside $self\n";

Outputs:

outside cat inside cat inside dog outside cat

Replies are listed 'Best First'.
Re^2: Not sure how to handle this scope
by Your Mother (Archbishop) on Aug 18, 2021 at 20:42 UTC

    It’s silly and off topic but I am compelled to quote it for the tangent.

    Outside of a dog, a book is a man’s best friend. Inside of a dog, it’s too dark to read.