-
Notifications
You must be signed in to change notification settings - Fork 0
/
log
executable file
·36 lines (25 loc) · 996 Bytes
/
log
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/perl -w
use strict;
#LOG program.
# defines command 'log' which creates text files auto-named with date and category.
#currently allows bad characters in filename, watch out.
#further todos:
# [] whitespace replacement doesn't filter out starting spaces
my ($invocation_command, $invocation_type,$note_title, $note_title_dashes, $date, $type, $file_handle, $filename);
$invocation_command = shift @ARGV;
$invocation_type = shift @ARGV;
$type = $invocation_type =~ s/(.*)/\U$1/r;
print "Enter title:\n";
chomp($note_title = <STDIN>);
$note_title_dashes = $note_title =~ s/\s/-/gr;
$date = time;
if ($invocation_command eq 'new') {
$filename = "$date"."_"."$type"."_"."$note_title_dashes".".txt\n";
}
#now I just need to make it write the file, and then I can go eat. Hackish way?
#NOTE: relies on unique timestamp to avoid overwriting files!
open FILEHANDLE, "> "."$filename";
print FILEHANDLE ":title: $note_title\n\n";
close FILEHANDLE;
system "gedit $filename";
exit;