I'd like to create a class that provides a bunch of assertion
methods, like Carp::Assert, etc. I want to have an object oriented
interface, so in some code I'm developing I would have:
use Devel::Assert;
my $tester = Devel::Assert->new( on_fail => carp ); # or on_fail
=> cluck, etc.
my $data_structure = blah_blah();
$tester->save($data_structure); # Saves a clone of the data in a
unique slot
#
# do stuff with $data_structure
#
$tester->has_changed($data_structure);
The trick I want is that if my code is running in a production
environment (perhaps determined at compile-time) then I want my
Devel::Assert stuff to basically disappear. So the question is, what
is the lowest-impact way to do that?
One easy, but probably not best way is to like this:
sub has_changed {
return if is_production();
# do actual stuff
}
I'll note here that Carp::Assert handles this issue by having you
make all the test calls conditional:
ASSERT( $a == $b) if DEBUG;
-M
-------------------------------------------------------
Matisse Enzer <[EMAIL PROTECTED]>
http://www.matisse.net/ - http://www.eigenstate.net/