Readonly::BeginLift - Readonly at BEGIN time
Version 0.03
use Readonly::BeginLift; Readonly my $VAR => 'foo'; Readonly::Scalar my $VAR2 => 'bar'; BEGIN { print $VAR, $VAR2 } __END__ foo,bar
The Readonly module exports the Readonly subroutine, but this subroutine executes at runtime. This module causes it to execute at BEGIN time. Thus:
Readonly
use strict; use warnings; use Readonly; use constant MY_VALUE => 'foo'; Readonly my $MY_VALUE => 'bar'; BEGIN { print MY_VALUE, "\n"; print $MY_VALUE, "\n"; }
That will print "foo" and issue an uninitialized value warning. One way to make it work is to do this:
use strict; use warnings; use Readonly; use constant MY_VALUE => 'foo'; my $MY_VALUE; BEGIN { Readonly my $MY_VALUE => 'bar'; print MY_VALUE, "\n"; print $MY_VALUE, "\n"; }
That's a bit clumsy, so we use Devel::BeginLift to make Readonly execute at begin time.
Devel::BeginLift
This is identical to the Readonly module, except that it happens at BEGIN time.
Curtis "Ovid" Poe, <ovid at cpan.org>
<ovid at cpan.org>
Please report any bugs or feature requests to bug-readonly-beginlift at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Readonly-BeginLift. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-readonly-beginlift at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc Readonly::BeginLift
You can also look for information at:
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Readonly-BeginLift
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/Readonly-BeginLift
CPAN Ratings
http://cpanratings.perl.org/d/Readonly-BeginLift
Search CPAN
http://search.cpan.org/dist/Readonly-BeginLift/
Thanks for Florian Ragwitz for Devel::BeginLift.
Copyright 2010 Curtis "Ovid" Poe, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Readonly::BeginLift, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Readonly::BeginLift
CPAN shell
perl -MCPAN -e shell install Readonly::BeginLift
For more information on module installation, please visit the detailed CPAN module installation guide.