use strict;
use vars '$x';
$x = 3;
sub critical {
my $w = 50;
# my $x = 100; # oops: commented out by mistake
# my $y = 200;
my $y = 300;
frobnicate( $w, $x, $y ); # that's the global $x in there!
}
####
use strict;
$MyModule::x = 3;
# ...
sub critical {
my $w = 50;
# my $x = 100; # oops: commented out by mistake
# my $y = 200;
my $y = 300;
frobnicate( $w, $x, $y ); # won't compile
}
####
sub that_uses_global_x_heavily {
our $x; # we drop the formalities locally
foobar( $x );
# ...
$x = tweak( $x );
# ...
and_one_more_thing( $x );
# ...
}