NAME

Readonly::BeginLift - Readonly at BEGIN time

VERSION

Version 0.03

SYNOPSIS

use Readonly::BeginLift;
Readonly         my $VAR  => 'foo';
Readonly::Scalar my $VAR2 => 'bar';
BEGIN { print $VAR, $VAR2 }
__END__
foo,bar

DESCRIPTION

The Readonly module exports the Readonly subroutine, but this subroutine executes at runtime. This module causes it to execute at BEGIN time. Thus:

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.

EXPORT

Readonly

This is identical to the Readonly module, except that it happens at BEGIN time.

AUTHOR

Curtis "Ovid" Poe, <ovid at cpan.org>

BUGS

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.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc Readonly::BeginLift

You can also look for information at:

ACKNOWLEDGEMENTS

Thanks for Florian Ragwitz for Devel::BeginLift.

COPYRIGHT & LICENSE

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.