Help for this page

Select Code to Download


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