1Const::Fast(3) User Contributed Perl Documentation Const::Fast(3)
2
3
4
6 Const::Fast - Facility for creating read-only scalars, arrays, and
7 hashes
8
10 Version 0.006
11
13 use Const::Fast;
14
15 const my $foo => 'a scalar value';
16 const my @bar => qw/a list value/;
17 const my %buz => (a => 'hash', of => 'something');
18
20 const $var, $value
21 const @var, @value...
22 const %var, %value...
23 This the only function of this module and it is exported by default. It
24 takes a scalar, array or hash lvalue as first argument, and a list of
25 one or more values depending on the type of the first argument as the
26 value for the variable. It will set the variable to that value and
27 subsequently make it readonly. Arrays and hashes will be made deeply
28 readonly.
29
30 Exporting is done using Sub::Exporter for flexibility on import.
31
33 This module was written because I stumbled on some serious issues of
34 Readonly that aren't easily fixable without breaking backwards
35 compatibility in subtle ways. In particular Readonly's use of ties is a
36 source of subtle bugs and bad performance. Instead, this module uses
37 the builtin readonly feature of perl, making access to the variables
38 just as fast as any normal variable without the weird side-effects of
39 ties. Readonly can do the same for scalars when Readonly::XS is
40 installed, but chooses not to do so in the most common case.
41
43 Leon Timmermans, "<leont at cpan.org>"
44
46 Please report any bugs or feature requests to "bug-const-fast at
47 rt.cpan.org", or through the web interface at
48 http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Const-Fast
49 <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Const-Fast>. I will be
50 notified, and then you'll automatically be notified of progress on your
51 bug as I make changes.
52
54 You can find documentation for this module with the perldoc command.
55
56 perldoc Const::Fast
57
58 You can also look for information at:
59
60 · RT: CPAN's request tracker
61
62 http://rt.cpan.org/NoAuth/Bugs.html?Dist=Const-Fast
63 <http://rt.cpan.org/NoAuth/Bugs.html?Dist=Const-Fast>
64
65 · AnnoCPAN: Annotated CPAN documentation
66
67 http://annocpan.org/dist/Const-Fast
68 <http://annocpan.org/dist/Const-Fast>
69
70 · CPAN Ratings
71
72 http://cpanratings.perl.org/d/Const-Fast
73 <http://cpanratings.perl.org/d/Const-Fast>
74
75 · Search CPAN
76
77 http://search.cpan.org/dist/Const-Fast/
78 <http://search.cpan.org/dist/Const-Fast/>
79
81 The interface for this module was inspired by Eric Roode's Readonly.
82 The implementation is inspired by doing everything the opposite way
83 Readonly does it.
84
86 Copyright 2010 Leon Timmermans.
87
88 This program is free software; you can redistribute it and/or modify it
89 under the terms of either: the GNU General Public License as published
90 by the Free Software Foundation; or the Artistic License.
91
92 See http://dev.perl.org/licenses/ for more information.
93
94
95
96perl v5.12.2 2010-11-02 Const::Fast(3)