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