BEGIN { my $id = 24601; sub get_id { return $id; } sub set_id { my ($new_val) = @_; $id = $new_val; } } sub foo { # .. lotsa code print "ID number is ", get_id(), "\n"; # .. still more code }