… | |
… | |
34 | use Pod::POM (); |
34 | use Pod::POM (); |
35 | use File::Path (); |
35 | use File::Path (); |
36 | use Storable (); # finally |
36 | use Storable (); # finally |
37 | use Fcntl (); |
37 | use Fcntl (); |
38 | use JSON::XS qw(encode_json decode_json); |
38 | use JSON::XS qw(encode_json decode_json); |
39 | |
39 | use Guard qw(guard); |
40 | =item guard { BLOCK } |
|
|
41 | |
|
|
42 | Returns an object that executes the given block as soon as it is destroyed. |
|
|
43 | |
|
|
44 | =cut |
|
|
45 | |
|
|
46 | sub guard(&) { |
|
|
47 | bless \(my $cb = $_[0]), "DC::Guard" |
|
|
48 | } |
|
|
49 | |
|
|
50 | sub DC::Guard::DESTROY { |
|
|
51 | ${$_[0]}->() |
|
|
52 | } |
|
|
53 | |
40 | |
54 | =item shorten $string[, $maxlength] |
41 | =item shorten $string[, $maxlength] |
55 | |
42 | |
56 | =cut |
43 | =cut |
57 | |
44 | |
… | |
… | |
167 | |
154 | |
168 | open my $fh, $file |
155 | open my $fh, $file |
169 | or return; |
156 | or return; |
170 | |
157 | |
171 | local $/; |
158 | local $/; |
172 | JSON::XS->new->utf8->relaxed->decode (<$fh>) |
159 | eval { JSON::XS->new->utf8->relaxed->decode (<$fh>) } |
173 | } |
160 | } |
174 | |
161 | |
175 | sub set_theme($) { |
162 | sub set_theme($) { |
176 | return if $RC_THEME eq $_[0]; |
163 | return if $RC_THEME eq $_[0]; |
177 | $RC_THEME = $_[0]; |
164 | $RC_THEME = $_[0]; |