-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNotes.pl
More file actions
executable file
·75 lines (49 loc) · 1.7 KB
/
Copy pathNotes.pl
File metadata and controls
executable file
·75 lines (49 loc) · 1.7 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/perl
#Notes.pl
#Grant Visker CSIS 400
use strict;
use warnings;
use CGI qw(:standard);
my $add_note = param("note");
my $add = param("add");
print "Content-Type: text/html \n\n";
open(DATA, "</home/pi/MagicMirror/modules/MMM-Notes/mirrorNotes.txt") or die "Couldn't open file mirrorNotes.txt, $!";
my @notes = <DATA>;
close(DATA);
my $size = scalar @notes;
if($add eq "add"){
open(DATA, ">>/home/pi/MagicMirror/modules/MMM-Notes/mirrorNotes.txt") or die "Couldn't open file mirrorNotes.txt, $!";
#open(DATA3, ">>/home/pi/MagicMirror/modules/MMM-Notes/mirrorNotes.html") or die "Couldn't open file mirrorNotes.html, $!";
print DATA $add_note;
print DATA ("\n");
#print DATA3 "<p><h2 style=\"text-align:center\">~ $add_note</h2></p>\n";
#print DATA3 "<br>";
close(DATA);
}else{
open(DATA2, '>', '/home/pi/MagicMirror/modules/MMM-Notes/mirrorNotes.txt') or die "Couldn't open file mirrorNotes.txt, $!";
#open(DATA3, '>', '/home/pi/MagicMirror/modules/MMM-Notes/mirrorNotes.html') or die "Couldn't open file mirrorNotes.txt, $!";
#print DATA3 "Content-Type: text/html \n\n";
#print DATA3 "<html><body>\n";
#print DATA3 "<p><h1 style=\"text-align:center\">Notes</h1></p>\n";
#print DATA2 "<p><h1 style=\"text-align:center\">Notes</h1></p>\n";
my $textIndex = 0;
foreach(@notes){
if($_ eq "$add_note\n"){
$_ = "x";
}
}
foreach(@notes){
if ($_ ne "x"){
print DATA2 $_;
#print DATA3 "<p><h2 style=\"text-align:center\">~ $_</h2></p>\n";
#print DATA3 "<br>";
}
}
#print DATA3 "</body></html>";
close(DATA2);
}
#close(DATA3);
print "<html><body>\n";
print "<p>Success!</p>\n";
print "<p><a href=\"/newNote.html\">Click Here For A New Entry</a></p>";
print "</body></html>";