|  line  | 
 stmt  | 
 bran  | 
 cond  | 
 sub  | 
 pod  | 
 time  | 
 code  | 
| 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 package Petal::Utils::Base;  | 
| 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #rename: package Petal::Plugin; ?  | 
| 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
5
 | 
15
 | 
 
 | 
 
 | 
  
15
  
 | 
 
 | 
91944
 | 
 use strict;  | 
| 
 
 | 
15
 | 
 
 | 
 
 | 
 
 | 
 
 | 
28
 | 
    | 
| 
 
 | 
15
 | 
 
 | 
 
 | 
 
 | 
 
 | 
509
 | 
    | 
| 
6
 | 
15
 | 
 
 | 
 
 | 
  
15
  
 | 
 
 | 
80
 | 
 use warnings::register;  | 
| 
 
 | 
15
 | 
 
 | 
 
 | 
 
 | 
 
 | 
24
 | 
    | 
| 
 
 | 
15
 | 
 
 | 
 
 | 
 
 | 
 
 | 
2034
 | 
    | 
| 
7
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
8
 | 
15
 | 
 
 | 
 
 | 
  
15
  
 | 
 
 | 
95
 | 
 use Carp;  | 
| 
 
 | 
15
 | 
 
 | 
 
 | 
 
 | 
 
 | 
35
 | 
    | 
| 
 
 | 
15
 | 
 
 | 
 
 | 
 
 | 
 
 | 
14420
 | 
    | 
| 
9
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
10
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 our $VERSION  = ((require Petal::Utils), $Petal::Utils::VERSION)[1];  | 
| 
11
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 our $REVISION = (split(/ /, ' $Revision: 1.5 $ '))[2];  | 
| 
12
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
13
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 ## Define the enclosed packages inside the Petal Modifiers hash  | 
| 
14
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub install {  | 
| 
15
 | 
75
 | 
 
 | 
 
 | 
  
75
  
 | 
  
0
  
 | 
112
 | 
     my $class = shift;  | 
| 
16
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
17
 | 
75
 | 
 
 | 
 
 | 
 
 | 
 
 | 
886
 | 
     foreach my $name ($class->name, $class->aliases) {  | 
| 
18
 | 
90
 | 
 
 | 
 
 | 
 
 | 
 
 | 
576
 | 
 	$Petal::Hash::MODIFIERS->{"$name:"} = $class;  | 
| 
19
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
20
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
21
 | 
75
 | 
 
 | 
 
 | 
 
 | 
 
 | 
213
 | 
     return $class;  | 
| 
22
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
23
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
24
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub process {  | 
| 
25
 | 
0
 | 
 
 | 
 
 | 
  
0
  
 | 
  
0
  
 | 
0
 | 
     my $class = shift;  | 
| 
26
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
0
 | 
     confess( "$class does not override process()" );  | 
| 
27
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
28
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
29
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub name {  | 
| 
30
 | 
0
 | 
 
 | 
 
 | 
  
0
  
 | 
  
0
  
 | 
0
 | 
     my $class = shift;  | 
| 
31
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
0
 | 
     confess( "$class does not override name()" );  | 
| 
32
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
33
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
34
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub aliases {  | 
| 
35
 | 
0
 | 
 
 | 
 
 | 
  
0
  
 | 
  
0
  
 | 
0
 | 
     my $class = shift;  | 
| 
36
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
0
 | 
     confess( "$class does not override aliases()" );  | 
| 
37
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
38
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
39
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub split_first_arg {  | 
| 
40
 | 
9
 | 
 
 | 
 
 | 
  
9
  
 | 
  
0
  
 | 
5128
 | 
     my $class = shift;  | 
| 
41
 | 
9
 | 
 
 | 
 
 | 
 
 | 
 
 | 
14
 | 
     my $args  = shift;  | 
| 
42
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     # don't use split(/\s/,...) as we might kill an expression that way  | 
| 
43
 | 
9
 | 
 
 | 
 
 | 
 
 | 
 
 | 
78
 | 
     return ($args =~ /\A(.+?)\s+(.*)\z/);  | 
| 
44
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
45
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
46
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 # Return a list of all arguments as an array - does not perform expansion on  | 
| 
47
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 # embedded modifiers  | 
| 
48
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub split_args {  | 
| 
49
 | 
40
 | 
 
 | 
 
 | 
  
40
  
 | 
  
0
  
 | 
5919
 | 
   my $class = shift;  | 
| 
50
 | 
40
 | 
 
 | 
 
 | 
 
 | 
 
 | 
57
 | 
   my ($args) = @_;  | 
| 
51
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
   # W. Smith's regex  | 
| 
52
 | 
40
 | 
 
 | 
 
 | 
 
 | 
 
 | 
500
 | 
   return ($args =~ /('[^']+'|\S+)/g);  | 
| 
53
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
54
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
55
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 # Returns an argument from the data hash as a string/object or as a plaintext  | 
| 
56
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 # if arg is surrounded by single quotes or a number (decimal points OK)  | 
| 
57
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 # Arguments:  | 
| 
58
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #   $hash - reference to the Petal data hash  | 
| 
59
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #   $arg - the argument  | 
| 
60
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub fetch_arg {  | 
| 
61
 | 
69
 | 
 
 | 
 
 | 
  
69
  
 | 
  
0
  
 | 
2034
 | 
   my $class = shift;  | 
| 
62
 | 
69
 | 
 
 | 
 
 | 
 
 | 
 
 | 
110
 | 
   my ($hash, $arg) = @_;  | 
| 
63
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
64
 | 
69
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
149
 | 
   return undef unless defined($arg);  | 
| 
65
 | 
64
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
230
 | 
   if($arg =~ /\'/) {  | 
| 
 
 | 
 
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
66
 | 
22
 | 
 
 | 
 
 | 
 
 | 
 
 | 
56
 | 
     $arg =~ s/\'//g;  | 
| 
67
 | 
22
 | 
 
 | 
 
 | 
 
 | 
 
 | 
68
 | 
     return $arg;  | 
| 
68
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
   }  | 
| 
69
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
   elsif($arg =~ /^[0-9.]+$/) {  | 
| 
70
 | 
13
 | 
 
 | 
 
 | 
 
 | 
 
 | 
41
 | 
     return $arg;  | 
| 
71
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
   }  | 
| 
72
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
   else {  | 
| 
73
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     #warn "Returning hash key for $arg";  | 
| 
74
 | 
29
 | 
 
 | 
 
 | 
 
 | 
 
 | 
105
 | 
     return $hash->fetch($arg);  | 
| 
75
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
   }  | 
| 
76
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
77
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
78
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
79
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
80
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
81
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 1;  | 
| 
82
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    |