$v=~s/\s+//g;
if(! -e $v){
$path = substr($path, 0, rindex($cnf_file,'/')) .'/'.$v;
+ }else{
+ $path = $v;
}
foreach(@files){
return if $_ eq $path
read $fh, my $content, -s $fh;
close $fh;
#
- push @files, $path;
+ push @files, $path;
my @tags = ($content =~ m/<<(\w*<(.*?).*?>>)/gs);
- foreach my $tag (@tags){
- next if not $tag;
- my @kv = split /</,$tag;
- $e = $kv[0];
- $tag = $kv[1];
- $i = index $tag, "\n";
- if($i==-1){
- $tag = $v = substr $tag, 0, (rindex $tag, ">>");
- }
- else{
- $v = substr $tag, $i+1, (rindex $tag, ">>")-($i+1);
- $tag = substr $tag, 0, $i;
- }
- if($tag eq 'DATA'){
- $self->doDATAInstructions_($e,$v)
- }
+ if(@tags>0){
+ foreach my $tag (@tags){
+ next if not $tag;
+ my @kv = split /</,$tag;
+ $e = $kv[0];
+ $tag = $kv[1];
+ $i = index $tag, "\n";
+ if($i==-1){
+ $tag = $v = substr $tag, 0, (rindex $tag, ">>");
+ }
+ else{
+ $v = substr $tag, $i+1, (rindex $tag, ">>")-($i+1);
+ $tag = substr $tag, 0, $i;
+ }
+ if($tag eq 'DATA'){
+ $self->doDATAInstructions_($e,$v)
+ }
+ }
+ }else{
+ $self->doDATAInstructions_($e,$content)
}
}
##
if(not $content){
open(my $fh, "<:perlio", $cnf_file ) or die "Can't open $cnf_file -> $!";
- read $fh, $content, -s $fh;
- close $fh;
+ read $fh, $content, -s $fh;
+ close $fh;
my @stat = stat($cnf_file);
$self->{CNF_STAT} = \@stat;
$self->{CNF_CONTENT} = $CUR_SCRIPT = $cnf_file;
}
$self->{CNF_VERSION} = $CNF_VER;
- my $spc = $content =~ /\n/ ? '(<{2,3}?)(<*.*?>*)(>{2,3})' : '(<{2,3}?)(<*.*?>*?)(>{2,3})$';
+ my $spc = $content =~ /\n/ ? '(<{2,3}?)(<*.*?>*)(>{2,3})' : '\s*(<{2,3}?)(<*.*?>*?)(>{2,3})\s*$';
@tags = ($content =~ m/$spc/gms);
foreach my $tag (@tags){
--- /dev/null
+#!/usr/bin/env perl
+use warnings;
+use strict;
+
+use lib "tests";
+use lib "system/modules";
+
+require TestManager;
+require CNFParser;
+
+use Syntax::Keyword::Try;
+
+my $test = TestManager->new($0);
+my $cnf;
+
+try {
+ ###
+ # Test instance creation.
+ ###
+ die $test->failed() if not $cnf = CNFParser->new();
+ $test->case("Passed new instance CNFParser.");
+ #
+ $test->nextCase();
+ #
+ $test->case("Test FILE instruction loading the data.");
+ my $file = $0;
+ $file =~ s/\.pl$/.cnf/g;
+ $cnf->parse( undef, qq( << TEST <FILE> $file >> ) );
+ my $test_data = $cnf->data()->{TEST};
+ $test->isDefined( "\$test_data", $test_data );
+ my $ptr = $$test_data->{data};
+ $test->evaluate( "\@data size is one record?", 1, scalar(@$ptr) );
+ my @data = @$ptr;
+ $test->evaluate( "\@data[0][0] is 01?", '01', $data[0][0] );
+ $test->evaluate( "\@data[0][1] is 'test'?", 'test', $data[0][1] );
+ ###
+ #
+ $test->done();
+ #
+}
+catch {
+ $test->dumpTermination($@);
+ $test->doneFailed();
+}
+
+#
+# TESTING THE FOLLOWING IS FROM HERE #
+#