-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path4at.pl
More file actions
66 lines (65 loc) · 1.76 KB
/
4at.pl
File metadata and controls
66 lines (65 loc) · 1.76 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
#!/usr/perl
use strict;
use warnings;
print "This is 4AT Delirium Test Scoring Calculator\n";
print "===============================================\n";
print "I. Please, enter score for alertness [0 or 4]: ";
my $A = <>;
chomp $A;
while ($A < 0 || $A > 4 || $A == 1 || $A == 2 || $A == 3 || $A !~ /^[0-9]+$/ || $A eq ""){
print ("Value is out of range. Please, enter a valid number [0 or 4]: ");
$A = <>;
chomp $A;
}
print "II. Please, enter the score for AMT4 [0-2]: ";
my $AMT4 = <>;
chomp $AMT4;
while ($AMT4 < 0 || $AMT4 > 2 || $AMT4 !~ /^[0-9]+$/ || $AMT4 eq ""){
print ("Value is out of range. Please, enter a valid number [0-2]: ");
$AMT4 = <>;
chomp $AMT4;
}
print ("III. Please, enter the sore for attention [0-2]: ");
my $AT = <>;
chomp $AT;
while ($AT < 0 || $AT > 2 || $AT !~ /^[0-9]+$/ || $AT eq ""){
print ("Value is out of range. Please, enter a valid number [0-2]: ");
$AT = <>;
chomp $AT;
}
print ("IV. Please, enter the score for fluctuating course [0 or 4]: ");
my $F = <>;
chomp $F;
while ($F < 0 || $F > 4 || $F == 1 || $F == 2 || $F == 3 || $F !~ /^[0-9]+$/ || $F eq ""){
print ("Value is out of range. Please, enter a valid number [0 or 4]: ");
$F = <>;
chomp $F;
}
my $AT4 = $A + $AMT4 + $AT + $F;
print "\n";
print "The total score for 4AT is " . $AT4 . "/12\n";
print "\n";
while (1) {
print "Do you want to save the output to file (ace-r.txt) [yes/no]? ";
my $ans = lc(<STDIN>);
chomp($ans);
if ($ans eq 'yes') {
my $output = '4at.txt';
open(FH,'>', $output) or die $!;
print FH
my $str = <<END;
The total score for 4AT is $AT4/12
END
# print FH $str;
close(FH);
print "written to 4at.txt\n";
last;
}
elsif ($ans eq 'no') {
print "Not saved\n";
last;
}
else {
print "out of range, please answer [yes or no] ";
}
}