|
@@ -0,0 +1,40 @@
|
|
1
|
+package SugarTrail::STM;
|
|
2
|
+# STM holder
|
|
3
|
+# new()
|
|
4
|
+# parse_headers()
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+use strict;
|
|
9
|
+use warnings;
|
|
10
|
+use Carp;
|
|
11
|
+
|
|
12
|
+sub new {
|
|
13
|
+ my $class = shift;
|
|
14
|
+ my $args = { @_ };
|
|
15
|
+ my $self = {};
|
|
16
|
+ $self->{args} = $args;
|
|
17
|
+ return bless $self, $class;
|
|
18
|
+}
|
|
19
|
+
|
|
20
|
+sub parse_headers {
|
|
21
|
+ my $self = shift;
|
|
22
|
+
|
|
23
|
+ my ($head, $body) = split "\n\n", $self->{text}, 2;
|
|
24
|
+
|
|
25
|
+ my @lines = split "\n", $head;
|
|
26
|
+
|
|
27
|
+ $self->{head} = $head;
|
|
28
|
+ $self->{body} = $body;
|
|
29
|
+
|
|
30
|
+ foreach (@lines) {
|
|
31
|
+ my ($n, $v) = split ": ", $_, 2;
|
|
32
|
+ $self->{meta}->{$n} = $v;
|
|
33
|
+ }
|
|
34
|
+
|
|
35
|
+ return 1;
|
|
36
|
+
|
|
37
|
+}
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+1;
|