17 my $opentag = $config->{'moredata_opentag'} ? $config->{'moredata_opentag'} : ''; 19 my $closetag = $config->{'moredata_closetag'} ? $config->{'moredata_closetag'} : ''; # not required 24 $dataname = defined($val->[0]) ? $val->[0] : '' ; #dataname can be empty 25 $format = $val->[1] ? ($val->[1]) : $format_cfg ; 27 $dataname = $val ? $val : ''; #### 17 my $opentag = $config->{ moredata_opentag } || ''; 19 my $closetag = $config->{ moredata_closetag } || ''; # not required 24 $dataname = @$val ? $val->[0] : '' ; #dataname can be empty 25 $format = $val->[1] || $format_cfg ; 27 $dataname = $val || ''; #### 17 my $opentag = $config->{'moredata_opentag'} ? $config->{'moredata_opentag'} : ''; 18 die "MoreData requires an open tag: $!" unless ($opentag); 32 my $substrings_aref = _retrieve_strings($str, $opentag, $closetag, $dataname); 33 unless (scalar($substrings_aref)) { # no stringrefs returned 34 die "cannot extract substrings from string: $!"; 35 } 41 my $datasep_cfg = $config->{'moredata_datasep'}; 42 length($datasep_cfg) or die "The data separation string must be configured: $!"; 43 my $hashsep_cfg = $config->{'moredata_hashsep'} || ''; 44 length($hashsep_cfg) or die "The hash separation string must be configured: $!"; #### 17 my $opentag = $config->{ moredata_opentag } or die "MoreData requires an open tag\n"; 32 my $substrings_aref = _retrieve_strings($str, $opentag, $closetag, $dataname) or die "cannot extract substrings from string\n"; 41 my $datasep_cfg = $config->{ moredata_datasep } or die "The data separation string must be configured\n"; 43 my $hashsep_cfg = $config->{ moredata_hashsep } or die "The hash separation string must be configured\n"; #### 18 die "MoreData requires an open tag: $!" unless ($opentag); 30 die "No format specified in args or configuration: $!" unless $format; 33 unless (scalar($substrings_aref)) { # no stringrefs returned 34 die "cannot extract substrings from string: $!"; 35 } 42 length($datasep_cfg) or die "The data separation string must be configured: $!"; 44 length($hashsep_cfg) or die "The hash separation string must be configured: $!"; 52 } else { 53 die "no format : $!"; 54 } #### 72 die "Count of $count is not a pair of values in hash assignment of values @array : $!" if ($count != (2 || 0)); #### 98 my @substrings = ($content, $datastring); 102 return \@substrings unless ($stringlength); 105 return \@substrings if ($openposition == -1); 121 @substrings = ($content, $datastring); 122 return \@substrings if ($dataname eq '__data__'); # return content and data as strings 123 return \@substrings if ($dataname eq '__content__'); # return content and data as strings 124 return \@substrings unless length($datastring); # no reason to process empty datastring 130 @substrings = ($content, ''); 131 return \@substrings; 144 @substrings = ($content, $datastring); 145 return \@substrings; #### 102 return [$content, $datastring] unless ($stringlength); 105 return [$content, $datastring] if ($openposition == -1); 122 return [$content, $datastring] if ($dataname eq '__data__'); # return content and data as strings 123 return [$content, $datastring] if ($dataname eq '__content__'); # return content and data as strings 124 return [$content, $datastring] unless length($datastring); # no reason to process empty datastring 131 return [$content, '']; 145 return [$content, $datastring]; #### 148 sub _escape { 149 my $separator = shift; 150 my $regex = '\\' . join('\\', split(/''/, $separator) ); 151 return $regex; 152 } #### 64 sub _moredata_hash { 65 my ($datastring, $datasep, $hashsep) = @_; 68 my %hash; 69 my @list = split /\s*\Q$datasep\E\s*/, $datastring; 70 foreach my $item (@list) { 71 my $count = my @array = split(/\s*\Q$hashsep\E\s*/, $item); 72 die "Count of $count is not a pair of values in hash assignment of values @array : $!" if ($count != (2 || 0)); 73 $hash{$array[0]} = $array[1]; 74 } 75 scalar %hash ? \%hash : undef; 76 }