- or download this
use Loop::Watch;
my $x = 2;
ensure { $x > 0 } watching($x), doing {
# all your code centered around $x here
};
- or download this
package Tie::Scalar::Watch;
use Carp;
...
}
1;
- or download this
use Tie::Scalar::Watch; # imports 'watch'
my $x = 10;
...
print "$x\n";
$x--;
}
- or download this
sub STORE {
my ($self, $val) = @_;
$self->[0] = $val;
...
return $val :
croak "Value $val is out of bounds";
}