aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Lemon <matt@matthewlemon.com>2022-09-15 17:07:01 +0100
committerMatthew Lemon <matt@matthewlemon.com>2022-09-15 17:07:01 +0100
commit00a90f91bb3319e9cb89fa025c8d60314732ec7f (patch)
tree4240cb42d0fd245cb1ecf8a691c6513da619c233
parenteaf5fb1ae0fafad330447cf4cff75c7e8dd4e1f2 (diff)
wip: refactor
-rwxr-xr-xdayplan.pl22
1 files changed, 14 insertions, 8 deletions
diff --git a/dayplan.pl b/dayplan.pl
index 5bea7f7..d8aef33 100755
--- a/dayplan.pl
+++ b/dayplan.pl
@@ -11,8 +11,8 @@ my @qfiles;
my ($dt, $d, $y, $m, $weekday);
my @weekdays = qw(Monday Tuesday Wednesday Thursday Friday Saturday Sunday);
-my $dayplans = '/home/lemon/Notes/journal/day_plans';
-#my $dayplans = '/tmp';
+#my $dayplans = '/home/lemon/Notes/journal/day_plans';
+my $dayplans = '/tmp';
my $numargs = $#ARGV + 1;
@@ -98,13 +98,10 @@ $s
16:00 - 17:00 -
";
-my $today_planner = sprintf("%s/%d-%02d-%02d.txt", $dayplans,$y,$m,$d);
+sub write_file {
+ my $f = shift;
-if (-e $today_planner) {
- exec("vim", "$today_planner");
-} else
-{
- open( FH, ">$today_planner");
+ open( FH, ">$f");
print FH $template;
my $today = DateTime->today;
if ($today != $dt) {
@@ -112,5 +109,14 @@ if (-e $today_planner) {
}
close FH;
+ exec("vim", "$f");
+}
+
+my $today_planner = sprintf("%s/%d-%02d-%02d.txt", $dayplans,$y,$m,$d);
+
+if (-e $today_planner) {
exec("vim", "$today_planner");
+} else
+{
+ write_file($today_planner)
}