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