| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Spreadsheet::Open; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
232538
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
39
|
|
|
4
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
58
|
|
|
5
|
1
|
|
|
1
|
|
1479
|
use Log::ger; |
|
|
1
|
|
|
|
|
61
|
|
|
|
1
|
|
|
|
|
4
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
595
|
use File::Which; |
|
|
1
|
|
|
|
|
1086
|
|
|
|
1
|
|
|
|
|
81
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
6
|
use Exporter qw(import); |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
208
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY |
|
12
|
|
|
|
|
|
|
our $DATE = '2023-11-09'; # DATE |
|
13
|
|
|
|
|
|
|
our $DIST = 'Spreadsheet-Open'; # DIST |
|
14
|
|
|
|
|
|
|
our $VERSION = '0.002'; # VERSION |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our @EXPORT_OK = qw(open_spreadsheet); |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my @libreoffice_versions = qw( |
|
19
|
|
|
|
|
|
|
7.5 7.4 7.3 7.2 7.1 7.0 |
|
20
|
|
|
|
|
|
|
6.4 6.3 6.2 6.1 |
|
21
|
|
|
|
|
|
|
); |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
my @known_commands = ( |
|
24
|
|
|
|
|
|
|
# [os, program, params] |
|
25
|
|
|
|
|
|
|
['', 'libreoffice', ['--calc']], |
|
26
|
|
|
|
|
|
|
(map { ['', "libreoffice$_", ['--calc']] } @libreoffice_versions), |
|
27
|
|
|
|
|
|
|
); |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub open_spreadsheet { |
|
30
|
0
|
|
|
0
|
1
|
|
my $path = shift; |
|
31
|
|
|
|
|
|
|
|
|
32
|
0
|
|
|
|
|
|
for my $e (@known_commands) { |
|
33
|
0
|
0
|
0
|
|
|
|
next if $e->[0] && $^O ne $e->[0]; |
|
34
|
0
|
|
|
|
|
|
my $which = which($e->[1]); |
|
35
|
0
|
0
|
|
|
|
|
next unless $which; |
|
36
|
0
|
|
|
|
|
|
log_trace "Opening file %s in spreadsheet program %s ...", |
|
37
|
|
|
|
|
|
|
$path, $which; |
|
38
|
0
|
|
|
|
|
|
return system($which, @{ $e->[2] }, $path); |
|
|
0
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
log_trace "Falling back to using Desktop::Open ..."; |
|
42
|
0
|
|
|
|
|
|
require Desktop::Open; |
|
43
|
0
|
|
|
|
|
|
return Desktop::Open::open_desktop($path); |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
1; |
|
47
|
|
|
|
|
|
|
# ABSTRACT: Open spreadsheet in a spreadsheet program |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
__END__ |