#
package CNFMeta;
-use strict;
-use warnings; no warnings qw(experimental::signatures);
-use constant VERSION => "2.0";
+use strict; use warnings; no warnings qw(experimental::signatures);
+use constant {
+ VERSION => "2.0", #Version of CNFMeta itself is this, not exported, access with CNFMeta::VERSION.
+ DELIMITER => qr/(?:,\s*)|\s+/, # match a comma or whitespace
+ WILDCARD => qr/[\*\?]/, # wildcards: *.html foo??.txt
+ PRIORITY => qr/(\s*\_+PRIORITY\_(\d+)\_+\s*)/o, # Priority order no. for instructions.
+ ANN => '__ANN__' # ANONYMOUS tag name assigned where name is not given or tagged.
+};
###
# Returns the regular expression for any of the meta constances.
}
#
-###
-# Priority order no. for instructions.
-use constant PRIORITY => qr/(\s*\_+PRIORITY\_(\d+)\_+\s*)/o;
-###
-# ANONYMOUS tag name assigned where name is not given or tagged.
-use constant ANN => '__ANN__';
-
# We lock lookup hashes, in case they change in this package, to protect them, as READONLY.
# Will rise exceptions in outside older code not being updated to use new keys, or trying to modify them.
use Hash::Util qw(lock_hash);
# Global setting for SQL TEXT to CNF _TEXT_ specified data type range. Programmatically changeable.
our $SQL_CNF_VAR_LENGTH = 2024;
-sub import {
+###
+# All packages here are Perl required libraries not is in use CPAN's Exporter module.
+# When requiring CNFMeta this static method should be called to get its methods and constances()
+# imported into name space of your new package.
+# Caveat to such implementation is that on initial compile time syntax errors can not be apparent.
+# Advantage is that package name spaces are less convoluted.
+###
+sub _import_into_this_package {
my $caller = caller; no strict "refs";
{
# TREE instruction meta.
# resulting in unintended placings.
*{"${caller}::meta_node_in_shortife"} = sub {return _meta("IN_SHORTIFE")};
# Execute via system shell.
- *{"${caller}::meta"} = \&_meta;
- *{"${caller}::SHELL"} = sub {return _meta("SHELL")};
+ *{"${caller}::meta"} = \&_meta;
+ *{"${caller}::SHELL"} = sub {return _meta("SHELL")};
# Returns the regular expression for any of the meta constances.
+ *{"${caller}::ANN"} = \&ANN;
+ *{"${caller}::DELIMITER"} = \&DELIMITER;
+ *{"${caller}::WILDCARD"} = \&WILDCARD;
}
return 1;
}
+
###
# Data base conversion types supported from the CNF side.
###
use Syntax::Keyword::Try;
use Carp qw(cluck);
-require CNFMeta; CNFMeta::import();
+require CNFMeta; CNFMeta::_import_into_this_package();
sub new {
my ($class, $attrs) = @_;
use IO::Compress::Xz qw($XzError);
use IO::Uncompress::UnXz qw($UnXzError);
-require CNFMeta; CNFMeta::import();
+require CNFMeta; CNFMeta::_import_into_this_package();
require CNFNode;
require CNFDateTime;
sub blank{
return new(shift,undef,@_)
}
-
-sub import {
+## @see CNFMeta for explanation.
+sub _import_into_this_package {
my $caller = caller; no strict "refs";
{
*{"${caller}::configDumpENV"} = \&dumpENV;
*{"${caller}::anon"} = \&anon;
*{"${caller}::SQL"} = \&SQL;
- *{"${caller}::isCNFTrue"} = \&_isTrue;
- *{"${caller}::now"} = \&now;
+ *{"${caller}::isCNFTrue"} = \&_isTrue;
}
return 1;
}
}elsif($t eq 'TREE'){
my $tree = 0;
if( !$is_tagged){
- $e = CNFMeta::ANN();
+ $e = ANN();
}
if( $v =~ s/($meta_has_priority)/""/ei ){
$priority = 1;
my $ret;
if (!$v){
$v = $e;
- $e = CNFMeta::ANN();
+ $e = ANN();
}
if( $v =~ s/($meta_has_priority)/""/ei ){
$priority = 1;
my $priority = $struct-> {'^'};
if($type eq 'CNFNode' && $priority > 0 && $priority < 5){
$struct->validate() if $self->{ENABLE_WARNINGS};
- if($struct->name() eq CNFMeta::ANN()){
+ if($struct->name() eq ANN()){
my $anode = $struct->process($self, $struct->script());
foreach my $node($$anode->nodes()){
$anechoic ->{$node->name()} = \$node;
my $type = ref($struct);
if($type eq 'CNFNode'){
$struct->validate() if $self->{ENABLE_WARNINGS};
- if($struct->name() eq CNFMeta::ANN()){
+ if($struct->name() eq ANN()){
my $anode = $struct->process($self, $struct->script());
foreach my $node($$anode->nodes()){
$anechoic ->{$node->name()} = \$node;
use DBI;
use Date::Manip;
-require CNFDateTime; require CNFMeta; require CNFSQL;
+require CNFDateTime; require CNFMeta; require CNFSQL; CNFParser::_import_into_this_package();
use constant VERSION => '1.1';
my ($IS_SQLITE,$DSN,$SUPPRESS_DATA_LOG)=(0,(),0);
die "DB not set!" if !$dbname;
$IS_SQLITE = $datasource =~ /DBI:SQLite/i; $dbname .= '.db' if $IS_SQLITE && $dbname !~ /.db$/;
$DSN = $datasource .'dbname='.$dbname;
- $SUPPRESS_DATA_LOG = CNFParser::_isTrue($suppress_data_log);
- $is_auto_commit = CNFParser::_isTrue($is_auto_commit);
- $is_raise_error = CNFParser::_isTrue($is_raise_error);
+ $SUPPRESS_DATA_LOG = isCNFTrue($suppress_data_log);
+ $is_auto_commit = isCNFTrue($is_auto_commit);
+ $is_raise_error = isCNFTrue($is_raise_error);
$self->{DSN} = $DSN;
$self->{db_name} = $dbname;
$self->{is_sqlite} = $IS_SQLITE;