NAME
unconstant - sometimes you need to un- em'.
DESCRIPTION
This module provides an alternative implementation of constant. This implementation stops perl from inlining the constant, stops constant folding, and stops dead code removal.
This is supremely useful for testing where a package internally declares and uses a constant that you want to change. This is common when wanting to test modules that make use of constants.
Note: this module does NOT stop `use` from hoisting the statement to the top.
SYNOPSIS
# Disable constant optimizations in my_test
perl -Munconstant ./my_test.pl
package MyTest {
use constant BAR => 7;
sub baz { BAR }
}
# All of these will change the return of `MyTest::baz()`
package main {
use constant *MyTest::BAR => 42;
use constant "MyTest::BAR" => 42;
*MyTest::BAR = sub { 42 };
*MyTest::BAR = sub () { 42 };
}
AUTHOR
Evan Carroll, <me at evancarroll.com>
BUGS
Please report any bugs or feature requests to bug-unconstant at rt.cpan.org
, or through the web interface at https://rt.cpan.org/NoAuth/ReportBug.html?Queue=unconstant. 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 unconstant
You can also look for information at:
RT: CPAN's request tracker (report bugs here)
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
Search CPAN
LICENSE AND COPYRIGHT
This software is Copyright (c) 2019 by Evan Carroll.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)