Debian Codegraph @

README

raw
1 NAME
2
3 Lexical::Var - static variables without namespace pollution
4
5 DESCRIPTION
6
7 This module implements lexical scoping of static variables and
8 subroutines. Although it can be used directly, it is mainly intended
9 to be infrastructure for modules that manage namespaces.
10
11 This module influences the meaning of single-part variable names that
12 appear directly in code, such as "$foo". Normally, in the absence of any
13 particular declaration, or under the effect of an "our" declaration, this
14 would refer to the scalar variable of that name located in the current
15 package. A "Lexical::Var" declaration can change this to refer to any
16 particular scalar, bypassing the package system entirely. A variable
17 name that includes an explicit package part, such as "$main::foo", always
18 refers to the variable in the specified package, and is unaffected by this
19 module. A symbolic reference through a string value, such as "${'foo'}",
20 also looks in the package system, and so is unaffected by this module.
21
22 The types of name that can be influenced are scalar ("$foo"), array
23 ("@foo"), hash ("%foo"), subroutine ("&foo"), and glob ("*foo").
24 A definition for any of these names also affects code that logically
25 refers to the same entity, even when the name is spelled without its
26 usual sigil. For example, any definition of "@foo" affects element
27 references such as "$foo[0]". Barewords in filehandle context actually
28 refer to the glob variable. Bareword references to subroutines, such as
29 "foo(123)", only work on Perl 5.11.2 and later; on earlier Perls you
30 must use the "&" sigil, as in "&foo(123)".
31
32 Where a scalar name is defined to refer to a constant (read-only) scalar,
33 references to the constant through the lexical namespace can participate
34 in compile-time constant folding. This can avoid the need to check
35 configuration values (such as whether debugging is enabled) at runtime.
36
37 A name definition supplied by this module takes effect from the end
38 of the definition statement up to the end of the immediately enclosing
39 block, except where it is shadowed within a nested block. This is the
40 same lexical scoping that the "my", "our", and "state" keywords supply.
41 Definitions from Lexical::Var and from "my"/"our"/"state" can shadow
42 each other (except that Lexical::Var can't shadow a "my"/"our"/"state"
43 subroutine prior to Perl 5.19.1). These lexical definitions propagate
44 into string "eval"s, on Perl versions that support it (5.9.3 and later).
45
46 This module only manages variables of static duration (the kind of
47 duration that "our" and "state" variables have). To get a fresh variable
48 for each invocation of a function, use "my".
49
50 INSTALLATION
51
52 perl Build.PL
53 ./Build
54 ./Build test
55 ./Build install
56
57 AUTHOR
58
59 Andrew Main (Zefram) <[email protected]>
60
61 COPYRIGHT
62
63 Copyright (C) 2009, 2010, 2011, 2012, 2013, 2023
64 Andrew Main (Zefram) <[email protected]>
65
66 LICENSE
67
68 This module is free software; you can redistribute it and/or modify it
69 under the same terms as Perl itself.