This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perldelta 47836a13cc4c999c9b3589c6797d6769b52c37fd
[perl5.git] / lib / Config / Extensions.pm
1 package Config::Extensions;
2 use strict;
3 our (%Extensions, $VERSION, @ISA, @EXPORT_OK);
4 use Config;
5 require Exporter;
6
7 $VERSION = '0.02';
8 @ISA = 'Exporter';
9 @EXPORT_OK = '%Extensions';
10
11 foreach my $type (qw(static dynamic nonxs)) {
12     foreach (split /\s+/, $Config{$type . '_ext'}) {
13         s!/!::!g;
14         $Extensions{$_} = $type;
15     }
16 }
17
18 1;
19 __END__
20 =head1 NAME
21
22 Config::Extensions - hash lookup of which core extensions were built.
23
24 =head1 SYNOPSIS
25
26     use Config::Extensions '%Extensions';
27     if ($Extensions{PerlIO::via}) {
28         # This perl has PerlIO::via built
29     }
30
31 =head1 DESCRIPTION
32
33 The Config::Extensions module provides a hash C<%Extensions> containing all
34 the core extensions that were enabled for this perl. The hash is keyed by
35 extension name, with each entry having one of 3 possible values:
36
37 =over 4
38
39 =item dynamic
40
41 The extension is dynamically linked
42
43 =item nonxs
44
45 The extension is pure perl, so doesn't need linking to the perl executable
46
47 =item static
48
49 The extension is statically linked to the perl binary
50
51 =back
52
53 As all values evaluate to true, a simple C<if> test is good enough to determine
54 whether an extension is present.
55
56 All the data uses to generate the C<%Extensions> hash is already present in
57 the C<Config> module, but not in such a convenient format to quickly reference.
58
59 =head1 AUTHOR
60
61 Nicholas Clark <nick@ccl4.org>
62
63 =cut