Tie::CheckVariables - check/validate variables for their datatype


Tie-CheckVariables documentation  | view source Contained in the Tie-CheckVariables distribution.

Index


NAME

Top

Tie::CheckVariables - check/validate variables for their datatype

SYNOPSIS

Top

  use Tie::CheckVariables

  tie my $scalar,'Tie::CheckVariables','integer';
  $scalar = 88; # is ok
  $scalar = 'test'; # is not ok, throws error

  untie $scalar;

DATATYPES

Top

You can use these datatypes:

* integer
* float
* string

WHAT TO DO WHEN CHECK FAILS

Top

on_error

You can specify a subroutine that is invoked on error:

  use Tie::CheckVariables;

  Tie::CheckVariables->on_error(sub{print "ERROR!"});

  tie my $scalar,'Tie::CheckVariables','integer';
  $scalar = 'a'; # ERROR! is printed
  untie $scalar;

USE YOUR OWN DATATYPE

Top

register

If the built-in datatypes aren't enough, you can extend this module with your own datatypes:

  use Tie::CheckVariables;

  Tie::CheckVariables->register('url','^http://');
  tie my $test_url,'Tie::CheckVariables','url';
  $test_url = 'http://www.perl.org';
  untie $test_url;

BUGS

Top

No known bugs, but "every" piece of code has bugs. If you find bugs, please use http://rt.cpan.org

AUTHOR

Top

copyright 2006 Renee Baecker <module@renee-baecker.de>


Tie-CheckVariables documentation  | view source Contained in the Tie-CheckVariables distribution.