VarGuard

 view release on metacpan or  search on metacpan

lib/VarGuard.pm  view on Meta::CPAN


=cut

use base qw(Exporter);
our @EXPORT = qw(var_guard);

use VarGuard::Scalar;
use VarGuard::Array;
use VarGuard::Hash;

sub var_guard(&\[$@%*]) {
    my($cb, $var) = @_;
    my $ref_type = ref $var;
    if( $ref_type eq 'SCALAR' or $ref_type eq 'CODE' ) {
	tie $$var, 'VarGuard::Scalar', $cb;
    }
    elsif( $ref_type eq 'ARRAY' ) {
	tie @$var, 'VarGuard::Array', $cb;
    }
    elsif( $ref_type eq 'HASH' ) {
	tie %$var, 'VarGuard::Hash', $cb;



( run in 0.747 second using v1.01-cache-2.11-cpan-49f99fa48dc )