unconstant - sometimes you need to un- em'.
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.
# 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 }; }
Evan Carroll, <me at evancarroll.com>
<me at evancarroll.com>
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.
bug-unconstant at rt.cpan.org
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)
https://rt.cpan.org/NoAuth/Bugs.html?Dist=unconstant
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/unconstant
CPAN Ratings
https://cpanratings.perl.org/d/unconstant
Search CPAN
https://metacpan.org/release/unconstant
This software is Copyright (c) 2019 by Evan Carroll.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)
To install unconstant, copy and paste the appropriate command in to your terminal.
cpanm
cpanm unconstant
CPAN shell
perl -MCPAN -e shell install unconstant
For more information on module installation, please visit the detailed CPAN module installation guide.