bin/kv

Fri, 29 Dec 2023 03:02:51 -0600

author
Meredith Howard <mhoward@roomag.org>
date
Fri, 29 Dec 2023 03:02:51 -0600
changeset 1139
1359a563b5ce
parent 1115
15ca9da8cd59
child 1142
dd4f69be5e32
permissions
-rwxr-xr-x

split out LuaSnip spec

1115
15ca9da8cd59 use distinct db for update checks
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1 #!/usr/bin/env perl
15ca9da8cd59 use distinct db for update checks
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2 use v5.32;
15ca9da8cd59 use distinct db for update checks
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
3 use Fcntl;
15ca9da8cd59 use distinct db for update checks
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
4 use AnyDBM_File;
15ca9da8cd59 use distinct db for update checks
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
5
15ca9da8cd59 use distinct db for update checks
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
6 my ($filename, $method, @args) = @ARGV;
15ca9da8cd59 use distinct db for update checks
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
7
15ca9da8cd59 use distinct db for update checks
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
8 tie my %h, 'AnyDBM_File', $filename, O_RDWR|O_CREAT, 0660
15ca9da8cd59 use distinct db for update checks
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
9 or die "tie $filename: $!";
15ca9da8cd59 use distinct db for update checks
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
10
15ca9da8cd59 use distinct db for update checks
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
11 $, = "\n";
15ca9da8cd59 use distinct db for update checks
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
12
15ca9da8cd59 use distinct db for update checks
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
13 say main->can($method)->(@args);
15ca9da8cd59 use distinct db for update checks
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
14
15ca9da8cd59 use distinct db for update checks
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
15 sub get { $h{+shift} }
15ca9da8cd59 use distinct db for update checks
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
16 sub set { $h{$_[0]} = $_[1] and exit }
15ca9da8cd59 use distinct db for update checks
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
17 sub del { delete $h{+shift} }
15ca9da8cd59 use distinct db for update checks
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
18
15ca9da8cd59 use distinct db for update checks
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
19 sub touch { $h{+shift} = time and exit }
15ca9da8cd59 use distinct db for update checks
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
20 sub age { time - $h{+shift} }
15ca9da8cd59 use distinct db for update checks
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
21 sub age_days { int(age(shift) / 86_400) }
15ca9da8cd59 use distinct db for update checks
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
22 sub age_days_gt { exit 0+!(age_days(shift) > shift) }
15ca9da8cd59 use distinct db for update checks
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
23
15ca9da8cd59 use distinct db for update checks
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
24 sub keys { keys %h }
15ca9da8cd59 use distinct db for update checks
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
25 sub dump { map { "$_ = $h{$_}" } keys %h }

mercurial