| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
#!/usr/bin/perl |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=pod |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME speak |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
Simply speaks the passed in message, clipboard or file |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 VERSION |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=over |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=item Author |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Andrew DeFaria |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=item Created: |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
Wed 24 Feb 2021 12:01:12 PM PST |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=back |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
Usage: speak [-usa|ge] [-h|elp] [-v|erbose] [-de|bug] |
|
26
|
|
|
|
|
|
|
[-c|lipboard] [-f|ile ] ["message"] |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
Where: |
|
29
|
|
|
|
|
|
|
-usa|ge: Print this usage |
|
30
|
|
|
|
|
|
|
-h|elp: Detailed help |
|
31
|
|
|
|
|
|
|
-c|lipboard: Speak the contents of the clipboard |
|
32
|
|
|
|
|
|
|
-f|ile Speak the contents of |
|
33
|
|
|
|
|
|
|
"message" Speak the message |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
This script speaks the contents of the passed in message, clipboard or file |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=cut |
|
40
|
|
|
|
|
|
|
|
|
41
|
1
|
|
|
1
|
|
4384
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
30
|
|
|
42
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
64
|
|
|
43
|
|
|
|
|
|
|
|
|
44
|
1
|
|
|
1
|
|
760
|
use Getopt::Long; |
|
|
1
|
|
|
|
|
15164
|
|
|
|
1
|
|
|
|
|
4
|
|
|
45
|
1
|
|
|
1
|
|
647
|
use Pod::Usage; |
|
|
1
|
|
|
|
|
70003
|
|
|
|
1
|
|
|
|
|
157
|
|
|
46
|
|
|
|
|
|
|
|
|
47
|
1
|
|
|
1
|
|
641
|
use Speak qw(speak); |
|
|
1
|
|
|
|
|
15
|
|
|
|
1
|
|
|
|
|
116
|
|
|
48
|
1
|
|
|
1
|
|
9
|
use Clipboard; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
10
|
|
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub error { |
|
51
|
0
|
|
|
0
|
|
|
my ($msg, $exit_code) = @_; |
|
52
|
0
|
|
|
|
|
|
print STDERR "ERROR: $msg\n"; |
|
53
|
0
|
|
0
|
|
|
|
exit ($exit_code || 1); |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
|
|
56
|
1
|
|
|
|
|
267562
|
my $verbose = 0; |
|
57
|
1
|
|
|
|
|
3
|
my $debug = 0; |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
my %opts = ( |
|
60
|
0
|
|
|
0
|
|
0
|
usage => sub {pod2usage}, |
|
61
|
0
|
|
|
0
|
|
0
|
help => sub {pod2usage (-verbose => 2)}, |
|
62
|
|
|
|
|
|
|
## no critic (Variables::RequireLocalizedPunctuationVars) |
|
63
|
0
|
|
|
0
|
|
0
|
verbose => sub {$verbose = 1; $ENV{VERBOSE} = 1}, |
|
|
0
|
|
|
|
|
0
|
|
|
64
|
0
|
|
|
0
|
|
0
|
debug => sub {$debug = 1; $ENV{DEBUG} = 1}, |
|
|
0
|
|
|
|
|
0
|
|
|
65
|
1
|
|
|
|
|
27
|
); |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
## Main |
|
68
|
1
|
50
|
|
|
|
11
|
GetOptions (\%opts, 'usage', 'help', 'verbose', 'debug', 'clipboard', 'file=s',) |
|
69
|
|
|
|
|
|
|
|| pod2usage; |
|
70
|
|
|
|
|
|
|
|
|
71
|
1
|
|
|
|
|
1316
|
my $msg = join ' ', @ARGV; |
|
72
|
|
|
|
|
|
|
|
|
73
|
1
|
50
|
|
|
|
8
|
if ($opts{clipboard}) { |
|
|
|
50
|
|
|
|
|
|
|
74
|
0
|
0
|
|
|
|
0
|
if ($opts{file}) { |
|
|
|
0
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
0
|
error 'Cannot specify both -clipboard and -file', 1; |
|
76
|
|
|
|
|
|
|
} elsif ($msg) { |
|
77
|
0
|
|
|
|
|
0
|
error 'Cannot specify both -clipboard and ', 1; |
|
78
|
|
|
|
|
|
|
} else { |
|
79
|
0
|
|
|
|
|
0
|
$msg = Clipboard->paste; |
|
80
|
|
|
|
|
|
|
} # if |
|
81
|
|
|
|
|
|
|
} elsif ($opts{file}) { |
|
82
|
1
|
50
|
|
|
|
3
|
if ($msg) { |
|
83
|
0
|
|
|
|
|
0
|
error 'Cannot specify both -file and ', 1; |
|
84
|
|
|
|
|
|
|
} else { |
|
85
|
|
|
|
|
|
|
open my $file, '<', $opts{file} |
|
86
|
1
|
50
|
|
|
|
66
|
or error "Unable to open $opts{file} - $!", 1; |
|
87
|
|
|
|
|
|
|
|
|
88
|
1
|
|
|
|
|
3
|
$msg = do {local $/; <$file>}; |
|
|
1
|
|
|
|
|
6
|
|
|
|
1
|
|
|
|
|
29
|
|
|
89
|
|
|
|
|
|
|
|
|
90
|
1
|
|
|
|
|
16
|
close $file; |
|
91
|
|
|
|
|
|
|
} # if |
|
92
|
|
|
|
|
|
|
} # if |
|
93
|
|
|
|
|
|
|
|
|
94
|
1
|
|
|
|
|
8
|
speak $msg; |