line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
714
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
39
|
|
2
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
273
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Perl::OSType; |
5
|
|
|
|
|
|
|
# ABSTRACT: Map Perl operating system names to generic types |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '1.008'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
require Exporter; |
10
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( all => [qw( os_type is_os_type )] ); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our @EXPORT_OK = @{ $EXPORT_TAGS{all} }; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# originally taken from Module::Build by Ken Williams et al. |
17
|
|
|
|
|
|
|
my %OSTYPES = qw( |
18
|
|
|
|
|
|
|
aix Unix |
19
|
|
|
|
|
|
|
bsdos Unix |
20
|
|
|
|
|
|
|
beos Unix |
21
|
|
|
|
|
|
|
bitrig Unix |
22
|
|
|
|
|
|
|
dgux Unix |
23
|
|
|
|
|
|
|
dragonfly Unix |
24
|
|
|
|
|
|
|
dynixptx Unix |
25
|
|
|
|
|
|
|
freebsd Unix |
26
|
|
|
|
|
|
|
linux Unix |
27
|
|
|
|
|
|
|
haiku Unix |
28
|
|
|
|
|
|
|
hpux Unix |
29
|
|
|
|
|
|
|
iphoneos Unix |
30
|
|
|
|
|
|
|
irix Unix |
31
|
|
|
|
|
|
|
darwin Unix |
32
|
|
|
|
|
|
|
machten Unix |
33
|
|
|
|
|
|
|
midnightbsd Unix |
34
|
|
|
|
|
|
|
minix Unix |
35
|
|
|
|
|
|
|
mirbsd Unix |
36
|
|
|
|
|
|
|
next Unix |
37
|
|
|
|
|
|
|
openbsd Unix |
38
|
|
|
|
|
|
|
netbsd Unix |
39
|
|
|
|
|
|
|
dec_osf Unix |
40
|
|
|
|
|
|
|
nto Unix |
41
|
|
|
|
|
|
|
svr4 Unix |
42
|
|
|
|
|
|
|
svr5 Unix |
43
|
|
|
|
|
|
|
sco_sv Unix |
44
|
|
|
|
|
|
|
unicos Unix |
45
|
|
|
|
|
|
|
unicosmk Unix |
46
|
|
|
|
|
|
|
solaris Unix |
47
|
|
|
|
|
|
|
sunos Unix |
48
|
|
|
|
|
|
|
cygwin Unix |
49
|
|
|
|
|
|
|
os2 Unix |
50
|
|
|
|
|
|
|
interix Unix |
51
|
|
|
|
|
|
|
gnu Unix |
52
|
|
|
|
|
|
|
gnukfreebsd Unix |
53
|
|
|
|
|
|
|
nto Unix |
54
|
|
|
|
|
|
|
qnx Unix |
55
|
|
|
|
|
|
|
android Unix |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
dos Windows |
58
|
|
|
|
|
|
|
MSWin32 Windows |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
os390 EBCDIC |
61
|
|
|
|
|
|
|
os400 EBCDIC |
62
|
|
|
|
|
|
|
posix-bc EBCDIC |
63
|
|
|
|
|
|
|
vmesa EBCDIC |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
MacOS MacOS |
66
|
|
|
|
|
|
|
VMS VMS |
67
|
|
|
|
|
|
|
vos VOS |
68
|
|
|
|
|
|
|
riscos RiscOS |
69
|
|
|
|
|
|
|
amigaos Amiga |
70
|
|
|
|
|
|
|
mpeix MPEiX |
71
|
|
|
|
|
|
|
); |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub os_type { |
74
|
9
|
|
|
9
|
1
|
2956
|
my ($os) = @_; |
75
|
9
|
100
|
|
|
|
20
|
$os = $^O unless defined $os; |
76
|
9
|
|
100
|
|
|
66
|
return $OSTYPES{$os} || q{}; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub is_os_type { |
80
|
6
|
|
|
6
|
1
|
350
|
my ( $type, $os ) = @_; |
81
|
6
|
100
|
|
|
|
34
|
return unless $type; |
82
|
4
|
100
|
|
|
|
10
|
$os = $^O unless defined $os; |
83
|
4
|
|
|
|
|
7
|
return os_type($os) eq $type; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
1; |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=pod |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=encoding UTF-8 |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 NAME |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Perl::OSType - Map Perl operating system names to generic types |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 VERSION |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
version 1.008 |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 SYNOPSIS |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
use Perl::OSType ':all'; |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
$current_type = os_type(); |
105
|
|
|
|
|
|
|
$other_type = os_type('dragonfly'); # gives 'Unix' |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 DESCRIPTION |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Modules that provide OS-specific behaviors often need to know if |
110
|
|
|
|
|
|
|
the current operating system matches a more generic type of |
111
|
|
|
|
|
|
|
operating systems. For example, 'linux' is a type of 'Unix' operating system |
112
|
|
|
|
|
|
|
and so is 'freebsd'. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
This module provides a mapping between an operating system name as given by |
115
|
|
|
|
|
|
|
C<$^O> and a more generic type. The initial version is based on the OS type |
116
|
|
|
|
|
|
|
mappings provided in L and L. (Thus, |
117
|
|
|
|
|
|
|
Microsoft operating systems are given the type 'Windows' rather than 'Win32'.) |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head1 USAGE |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
No functions are exported by default. The export tag ":all" will export |
122
|
|
|
|
|
|
|
all functions listed below. |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head2 os_type() |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
$os_type = os_type(); |
127
|
|
|
|
|
|
|
$os_type = os_type('MSWin32'); |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
Returns a single, generic OS type for a given operating system name. With no |
130
|
|
|
|
|
|
|
arguments, returns the OS type for the current value of C<$^O>. If the |
131
|
|
|
|
|
|
|
operating system is not recognized, the function will return the empty string. |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head2 is_os_type() |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
$is_windows = is_os_type('Windows'); |
136
|
|
|
|
|
|
|
$is_unix = is_os_type('Unix', 'dragonfly'); |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
Given an OS type and OS name, returns true or false if the OS name is of the |
139
|
|
|
|
|
|
|
given type. As with C, it will use the current operating system as a |
140
|
|
|
|
|
|
|
default if no OS name is provided. |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=head1 SEE ALSO |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=over 4 |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=item * |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
L |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=back |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=for :stopwords cpan testmatrix url annocpan anno bugtracker rt cpants kwalitee diff irc mailto metadata placeholders metacpan |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head1 SUPPORT |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=head2 Bugs / Feature Requests |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
Please report any bugs or feature requests through the issue tracker |
159
|
|
|
|
|
|
|
at L. |
160
|
|
|
|
|
|
|
You will be notified automatically of any progress on your issue. |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=head2 Source Code |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
This is open source software. The code repository is available for |
165
|
|
|
|
|
|
|
public review and contribution under the terms of the license. |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
L |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
git clone https://github.com/dagolden/Perl-OSType.git |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=head1 AUTHOR |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
David Golden |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=head1 CONTRIBUTORS |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=for stopwords Chris 'BinGOs' Williams Jonas B. Nielsen Owain G. Ainsworth Paul Green Piotr Roszatycki |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=over 4 |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=item * |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
Chris 'BinGOs' Williams |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=item * |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
Jonas B. Nielsen |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=item * |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
Owain G. Ainsworth |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=item * |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
Paul Green |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=item * |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
Piotr Roszatycki |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
=back |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
This software is copyright (c) 2015 by David Golden. |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
208
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
=cut |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
__END__ |