|  line  | 
 stmt  | 
 bran  | 
 cond  | 
 sub  | 
 pod  | 
 time  | 
 code  | 
| 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 package XML::XPath::Helper::String;  | 
| 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
3
 | 
3
 | 
 
 | 
 
 | 
  
3
  
 | 
 
 | 
200888
 | 
 use 5.008;  | 
| 
 
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
27
 | 
    | 
| 
4
 | 
3
 | 
 
 | 
 
 | 
  
3
  
 | 
 
 | 
22
 | 
 use strict;  | 
| 
 
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
6
 | 
    | 
| 
 
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
88
 | 
    | 
| 
5
 | 
3
 | 
 
 | 
 
 | 
  
3
  
 | 
 
 | 
15
 | 
 use warnings;  | 
| 
 
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
5
 | 
    | 
| 
 
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
126
 | 
    | 
| 
6
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
7
 | 
3
 | 
 
 | 
 
 | 
  
3
  
 | 
 
 | 
18
 | 
 use Exporter 'import';  | 
| 
 
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
5
 | 
    | 
| 
 
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
249
 | 
    | 
| 
8
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
9
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 our $VERSION = '1.05';  | 
| 
10
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
11
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 our @EXPORT_OK = qw(quoted_string one_of_quoted not_one_of_quoted);  | 
| 
12
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
13
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 our %EXPORT_TAGS = (all => \@EXPORT_OK);  | 
| 
14
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
15
 | 
3
 | 
 
 | 
 
 | 
  
3
  
 | 
 
 | 
18
 | 
 use Carp;  | 
| 
 
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
6
 | 
    | 
| 
 
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
2006
 | 
    | 
| 
16
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
17
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
18
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
19
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub quoted_string {  | 
| 
20
 | 
15
 | 
  
100
  
 | 
 
 | 
  
15
  
 | 
  
1
  
 | 
2160
 | 
   @_ == 1 or croak("Wrong number of arguments");  | 
| 
21
 | 
14
 | 
 
 | 
 
 | 
 
 | 
 
 | 
29
 | 
   my $arg = shift;  | 
| 
22
 | 
14
 | 
 
 | 
 
 | 
 
 | 
 
 | 
20
 | 
   my $arg_scalar;  | 
| 
23
 | 
14
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
43
 | 
   if (ref($arg)) {  | 
| 
24
 | 
10
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
202
 | 
     croak("Argument must be a string or a reference to an array") unless ref($arg) eq 'ARRAY';  | 
| 
25
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
   } else {  | 
| 
26
 | 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
7
 | 
     $arg_scalar = 1;  | 
| 
27
 | 
4
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
9
 | 
     $arg = "" if !defined($arg);  | 
| 
28
 | 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
9
 | 
     $arg = [$arg];  | 
| 
29
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
   }  | 
| 
30
 | 
13
 | 
 
 | 
 
 | 
 
 | 
 
 | 
26
 | 
   my @result;  | 
| 
31
 | 
13
 | 
 
 | 
 
 | 
 
 | 
 
 | 
19
 | 
   foreach my $string (@{$arg}) {  | 
| 
 
 | 
13
 | 
 
 | 
 
 | 
 
 | 
 
 | 
29
 | 
    | 
| 
32
 | 
21
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
53
 | 
     if (index($string, "'") >= 0) {  | 
| 
33
 | 
10
 | 
 
 | 
 
 | 
 
 | 
 
 | 
18
 | 
       my @array;  | 
| 
34
 | 
10
 | 
 
 | 
 
 | 
 
 | 
 
 | 
55
 | 
       foreach my $substr (grep{length($_)} split(/('+)/, $string)) {  | 
| 
 
 | 
37
 | 
 
 | 
 
 | 
 
 | 
 
 | 
65
 | 
    | 
| 
35
 | 
32
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
68
 | 
         my $q = substr($substr, 0, 1) eq "'" ? '"' : "'";  | 
| 
36
 | 
32
 | 
 
 | 
 
 | 
 
 | 
 
 | 
70
 | 
         push(@array, "${q}${substr}${q}");  | 
| 
37
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
       }  | 
| 
38
 | 
10
 | 
 
 | 
 
 | 
 
 | 
 
 | 
41
 | 
       push(@result, 'concat(' . join(',', @array) . ')');  | 
| 
39
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     } else {  | 
| 
40
 | 
11
 | 
 
 | 
 
 | 
 
 | 
 
 | 
33
 | 
       push(@result, "'$string'");  | 
| 
41
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
42
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
   }  | 
| 
43
 | 
13
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
94
 | 
   return ($arg_scalar ? $result[0] : \@result);  | 
| 
44
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
45
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
46
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
47
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub one_of_quoted {  | 
| 
48
 | 
3
 | 
  
 50
  
 | 
 
 | 
  
3
  
 | 
  
1
  
 | 
94
 | 
   @_ > 0 or croak("Too few arguments");  | 
| 
49
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
7
 | 
   my ($array, $name) = @_;  | 
| 
50
 | 
3
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
11
 | 
   ref($array) eq 'ARRAY' or croak("Argument 1 must be an ARRAY ref");  | 
| 
51
 | 
3
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
8
 | 
   if (defined($name)) {  | 
| 
52
 | 
2
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
5
 | 
     ref($name) and croak("Argument 2 must be a scalar");  | 
| 
53
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
8
 | 
     return "$name=" . join(" or $name=", @{quoted_string($array)});  | 
| 
 
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
4
 | 
    | 
| 
54
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
   } else {  | 
| 
55
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
3
 | 
     my $values = quoted_string($array);  | 
| 
56
 | 
1
 | 
 
 | 
 
 | 
  
2
  
 | 
 
 | 
7
 | 
     return sub { return "$_[0]=" . join(" or $_[0]=", @{$values}); };  | 
| 
 
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
394
 | 
    | 
| 
 
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
13
 | 
    | 
| 
57
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
   }  | 
| 
58
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
59
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
60
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
61
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub not_one_of_quoted {  | 
| 
62
 | 
3
 | 
  
 50
  
 | 
 
 | 
  
3
  
 | 
  
1
  
 | 
513
 | 
   @_ > 0 or croak("Too few arguments");  | 
| 
63
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
7
 | 
   my ($array, $name) = @_;  | 
| 
64
 | 
3
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
11
 | 
   ref($array) eq 'ARRAY' or croak("Argument 1 must be an ARRAY ref");  | 
| 
65
 | 
3
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
8
 | 
   if (defined($name)) {  | 
| 
66
 | 
2
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
5
 | 
     ref($name) and croak("Argument 2 must be a scalar");  | 
| 
67
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
6
 | 
     return "$name!=" . join(" and $name!=", @{quoted_string($array)});  | 
| 
 
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
4
 | 
    | 
| 
68
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
   } else {  | 
| 
69
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
3
 | 
     my $values = quoted_string($array);  | 
| 
70
 | 
1
 | 
 
 | 
 
 | 
  
1
  
 | 
 
 | 
7
 | 
     return sub { return "$_[0]!=" . join(" and $_[0]!=", @{$values}); };  | 
| 
 
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
375
 | 
    | 
| 
 
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
6
 | 
    | 
| 
71
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
   }  | 
| 
72
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
73
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
74
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
75
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
76
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 1; # End of XML::XPath::Helper::String  | 
| 
77
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
78
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
79
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
80
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 __END__  |