VS::RuleEngine::Util - Utility functions for VS::RuleEngine


VS-RuleEngine documentation Contained in the VS-RuleEngine distribution.

Index


Code Index:

NAME

Top

VS::RuleEngine::Util - Utility functions for VS::RuleEngine

INTERFACE

Top

FUNCTIONS

is_existing_package ( PACKAGE )

Checks if the package PACKAGE is defined or not.

is_valid_name ( NAME )

Checks if the given NAME is a valid name to assign inputs, outputs, hooks, rules and actions.

is_valid_package_name ( NAME )

Checks if the given NAME is a valid package name or not.

EXPORTS

Top

Nonething by default.


VS-RuleEngine documentation Contained in the VS-RuleEngine distribution.

package VS::RuleEngine::Util;

use strict;
use warnings;

use Carp qw(croak);

require Exporter;

our @ISA = qw(Exporter);

our @EXPORT = qw();
our @EXPORT_OK = qw(
    is_existing_package
    is_valid_name 
    is_valid_package_name
);

our %EXPORT_TAGS = ();

sub is_valid_name {
    my $name = pop;
    
    return $name =~ m/^ [A-Za-z] [A-Za-z0-9_]* $/x;
}

sub is_valid_package_name {
    my $pkg = pop;
    
    return $pkg =~ m/[[:alpha:]_] \w* (?: (?: :: | ') \w+ )*/x; #
}

sub is_existing_package {
    my $package = pop;
    no strict 'refs';
    my $exists = defined *{$package . '::'} ? 1 : 0;
    return $exists;
}

1;
__END__