line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Readonly::BeginLift; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
62884
|
use warnings; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
85
|
|
4
|
2
|
|
|
2
|
|
14
|
use strict; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
116
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
2273
|
use Readonly; |
|
2
|
|
|
|
|
7335
|
|
|
2
|
|
|
|
|
245
|
|
7
|
2
|
|
|
2
|
|
3252
|
use Devel::BeginLift (); |
|
2
|
|
|
|
|
44156
|
|
|
2
|
|
|
|
|
134
|
|
8
|
|
|
|
|
|
|
Devel::BeginLift->setup_for( |
9
|
|
|
|
|
|
|
Readonly => [ |
10
|
|
|
|
|
|
|
qw( |
11
|
|
|
|
|
|
|
Readonly |
12
|
|
|
|
|
|
|
Scalar |
13
|
|
|
|
|
|
|
Array |
14
|
|
|
|
|
|
|
Hash |
15
|
|
|
|
|
|
|
) |
16
|
|
|
|
|
|
|
] |
17
|
|
|
|
|
|
|
); |
18
|
|
|
|
|
|
|
|
19
|
2
|
|
|
2
|
|
26
|
use parent 'Exporter'; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
16
|
|
20
|
|
|
|
|
|
|
our @EXPORT = 'Readonly'; |
21
|
|
|
|
|
|
|
our @EXPORT_OK = qw/Scalar Array Hash Scalar1 Array1 Hash1/; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 NAME |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
Readonly::BeginLift - Readonly at BEGIN time |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 VERSION |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
Version 0.03 |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=cut |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head1 SYNOPSIS |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
use Readonly::BeginLift; |
38
|
|
|
|
|
|
|
Readonly my $VAR => 'foo'; |
39
|
|
|
|
|
|
|
Readonly::Scalar my $VAR2 => 'bar'; |
40
|
|
|
|
|
|
|
BEGIN { print $VAR, $VAR2 } |
41
|
|
|
|
|
|
|
__END__ |
42
|
|
|
|
|
|
|
foo,bar |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head1 DESCRIPTION |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
The L module exports the C subroutine, but this subroutine |
47
|
|
|
|
|
|
|
executes at runtime. This module causes it to execute at BEGIN time. Thus: |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
use strict; |
50
|
|
|
|
|
|
|
use warnings; |
51
|
|
|
|
|
|
|
use Readonly; |
52
|
|
|
|
|
|
|
use constant MY_VALUE => 'foo'; |
53
|
|
|
|
|
|
|
Readonly my $MY_VALUE => 'bar'; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
BEGIN { |
56
|
|
|
|
|
|
|
print MY_VALUE, "\n"; |
57
|
|
|
|
|
|
|
print $MY_VALUE, "\n"; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
That will print "foo" and issue an uninitialized value warning. One way to |
61
|
|
|
|
|
|
|
make it work is to do this: |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
use strict; |
64
|
|
|
|
|
|
|
use warnings; |
65
|
|
|
|
|
|
|
use Readonly; |
66
|
|
|
|
|
|
|
use constant MY_VALUE => 'foo'; |
67
|
|
|
|
|
|
|
my $MY_VALUE; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
BEGIN { |
70
|
|
|
|
|
|
|
Readonly my $MY_VALUE => 'bar'; |
71
|
|
|
|
|
|
|
print MY_VALUE, "\n"; |
72
|
|
|
|
|
|
|
print $MY_VALUE, "\n"; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
That's a bit clumsy, so we use C to make C execute |
76
|
|
|
|
|
|
|
at begin time. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 EXPORT |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head2 C |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
This is identical to the L module, except that it happens at BEGIN |
83
|
|
|
|
|
|
|
time. |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 AUTHOR |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Curtis "Ovid" Poe, C<< >> |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 BUGS |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Please report any bugs or feature requests to C
|
92
|
|
|
|
|
|
|
rt.cpan.org>, or through the web interface at |
93
|
|
|
|
|
|
|
L. I will |
94
|
|
|
|
|
|
|
be notified, and then you'll automatically be notified of progress on your bug |
95
|
|
|
|
|
|
|
as I make changes. |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 SUPPORT |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
perldoc Readonly::BeginLift |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
You can also look for information at: |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=over 4 |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
L |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
L |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=item * CPAN Ratings |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
L |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=item * Search CPAN |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
L |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=back |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
Thanks for Florian Ragwitz for L. |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
Copyright 2010 Curtis "Ovid" Poe, all rights reserved. |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
134
|
|
|
|
|
|
|
under the same terms as Perl itself. |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=cut |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
1; |