3 package Config
::Perl
::V
;
12 # Characteristics of this binary (from libperl):
13 # Compile-time options: DEBUGGING PERL_DONT_CREATE_GVSV PERL_MALLOC_WRAP
14 # USE_64_BIT_INT USE_LARGE_FILES USE_PERLIO
16 # The list are as the perl binary has stored it in PL_bincompat_options
18 # perl.c line 1768 (first block)
19 # perl.h line 4454 (second block),
20 my %BTD = map { $_ => 0 } qw(
30 PERL_MEM_LOG_TIMESTAMP
37 DEBUG_LEAKING_SCALARS_FORK_DUMP
42 PERL_DEBUG_READONLY_OPS
49 PERL_OLD_COPY_ON_WRITE
52 PERL_USES_PL_PIDSTATUS
69 # These are all the keys that are
70 # 1. Always present in %Config (first block)
71 # 2. Reported by 'perl -V' (the rest)
89 package revision version_patchlevel_string
91 osname osvers archname
94 hint useposix d_sigaction
95 useithreads usemultiplicity
96 useperlio d_sfio uselargefiles usesocks
97 use64bitint use64bitall uselongdouble
98 usemymalloc bincompat5005
103 ccversion gccversion gccosandvers
104 intsize longsize ptrsize doublesize byteorder
105 d_longlong longlongsize d_longdbl longdblsize
106 ivtype ivsize nvtype nvsize lseektype lseeksize
113 libc so useshrplib libperl
116 dlsrc dlext d_dlsymun ccdlflags
130 for (split m/\n+/ => join "\n", @_) {
132 if (s/^Summary of my\s+(\S+)\s+\(\s*(.*?)\s*\)//) {
133 $config{"package"} = $1;
135 $rev =~ s/^ revision \s+ (\S+) \s*//x and $config{revision
} = $1;
136 $rev and $config{version_patchlevel_string
} = $rev;
140 my %kv = m/\G,?\s*([^=]+)=('[^']+?'|\S+)/gc;
142 while (my ($k, $v) = each %kv) {
145 $v =~ m/^'(.*)'$/ and $v = $1;
151 my $build = { %empty_build };
152 $build->{osname
} = $config{osname
};
164 my %args = ref $args eq "HASH" ?
%$args :
165 ref $args eq "ARRAY" ? @
$args : ();
167 #y $pv = qx[$^X -e"sub Config::myconfig{};" -V];
169 $pv =~ s{.*?\n\n}{}s;
170 $pv =~ s{\n(?: \s+|\t\s*)}{ }g;
174 my $build = { %empty_build };
175 $pv =~ m{^\s+Built under (.*)}m and $build->{osname
} = $1;
176 $pv =~ m{^\s+Compiled at (.*)}m and $build->{stamp
} = $1;
177 $pv =~ m{^\s+Locally applied patches:\s+(.*)}m and $build->{patches
} = [ split m/\s+/, $1 ];
178 $pv =~ m{^\s+Compile-time options:\s+(.*)}m and map { $build->{options
}{$_} = 1 } split m/\s+/, $1;
180 my @KEYS = keys %ENV;
182 map { $_ => $ENV{$_} } grep m/^PERL/ => @KEYS;
184 map { $env{$_} = $ENV{$_} } grep m{$args{env}} => @KEYS;
186 my %config = map { $_ => $Config{$_} } @config_vars;
190 environment
=> \
%env,
202 Config::Perl::V - Structured data retreival of perl -V output
208 my $local_config = Config::Perl::V::myconfig ();
209 print $local_config->{config}{osname};
215 Currently the only function. Documentation will follow.
219 Convert a sole 'perl -V' text block to a complete myconfig hash.
220 All unknown entries are defaulted.
224 This module was written to be able to return the configuration for the
225 currently used perl as deeply as needed for the CPANTESTERS framework.
226 Up until now they used the output of myconfig as a single text blob,
227 and so it was missing the vital binary characteristics of the running
228 perl and the optional applied patches.
232 Please feedback what is wrong
236 * Implement retreival functions/methods
237 * Document what is done and why
238 * Include the perl -V parse block from Andreas
242 H.Merijn Brand <h.m.brand@xs4all.nl>
244 =head1 COPYRIGHT AND LICENSE
246 Copyright (C) 1999-2009 H.Merijn Brand
248 This library is free software; you can redistribute it and/or modify
249 it under the same terms as Perl itself.