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)
98 git_uncommitted_changes
102 package revision version_patchlevel_string
104 osname osvers archname
107 hint useposix d_sigaction
108 useithreads usemultiplicity
109 useperlio d_sfio uselargefiles usesocks
110 use64bitint use64bitall uselongdouble
111 usemymalloc bincompat5005
116 ccversion gccversion gccosandvers
117 intsize longsize ptrsize doublesize byteorder
118 d_longlong longlongsize d_longdbl longdblsize
119 ivtype ivsize nvtype nvsize lseektype lseeksize
126 libc so useshrplib libperl
129 dlsrc dlext d_dlsymun ccdlflags
144 exists $conf->{config
}{Off_t
}
145 $conf->{derived
}{Off_t
} = delete $conf->{config
}{Off_t
};
146 exists $conf->{derived
}{Off_t
} && !exists $conf->{config
}{lseektype
} and
147 $conf->{config
}{lseektype
} = $conf->{derived
}{Off_t
};
154 for (split m/\n+/ => join "\n", @_) {
156 if (s/^Summary of my\s+(\S+)\s+\(\s*(.*?)\s*\)//) {
157 $config{"package"} = $1;
159 $rev =~ s/^ revision \s+ (\S+) \s*//x and $config{revision
} = $1;
160 $rev and $config{version_patchlevel_string
} = $rev;
164 my %kv = m/\G,?\s*([^=]+)=('[^']+?'|\S+)/gc;
166 while (my ($k, $v) = each %kv) {
169 $v =~ m/^'(.*)'$/ and $v = $1;
175 my $build = { %empty_build };
176 $build->{osname
} = $config{osname
};
188 my %args = ref $args eq "HASH" ?
%$args :
189 ref $args eq "ARRAY" ? @
$args : ();
191 #y $pv = qx[$^X -e"sub Config::myconfig{};" -V];
193 $pv =~ s{.*?\n\n}{}s;
194 $pv =~ s{\n(?: \s+|\t\s*)}{ }g;
198 my $build = { %empty_build };
199 $pv =~ m{^\s+Built under (.*)}m and $build->{osname
} = $1;
200 $pv =~ m{^\s+Compiled at (.*)}m and $build->{stamp
} = $1;
201 $pv =~ m{^\s+Locally applied patches:\s+(.*)}m and $build->{patches
} = [ split m/\s+/, $1 ];
202 $pv =~ m{^\s+Compile-time options:\s+(.*)}m and map { $build->{options
}{$_} = 1 } split m/\s+/, $1;
204 my @KEYS = keys %ENV;
206 map { $_ => $ENV{$_} } grep m/^PERL/ => @KEYS;
208 map { $env{$_} = $ENV{$_} } grep m{$args{env}} => @KEYS;
210 my %config = map { $_ => $Config{$_} } @config_vars;
214 environment
=> \
%env,
226 Config::Perl::V - Structured data retreival of perl -V output
232 my $local_config = Config::Perl::V::myconfig ();
233 print $local_config->{config}{osname};
239 This function will collect the data decribed in L<the hash structure> below,
243 Convert a sole 'perl -V' text block to a complete myconfig hash.
244 All unknown entries are defaulted.
246 =head2 The hash structure
248 The returned hash consists of 4 parts:
254 This information is extracted from the second block that is emitted by
255 C<perl -V>, and usually looks something like
257 Characteristics of this binary (from libperl):
258 Compile-time options: DEBUGGING USE_64_BIT_INT USE_LARGE_FILES
259 Locally applied patches:
263 Compiled at Jun 13 2005 10:44:20
265 /usr/lib/perl5/5.8.7/i686-linux-64int
267 /usr/lib/perl5/site_perl/5.8.7/i686-linux-64int
268 /usr/lib/perl5/site_perl/5.8.7
269 /usr/lib/perl5/site_perl
274 Characteristics of this binary (from libperl):
275 Compile-time options: DEBUGGING MULTIPLICITY
276 PERL_DONT_CREATE_GVSV PERL_IMPLICIT_CONTEXT
277 PERL_MALLOC_WRAP PERL_TRACK_MEMPOOL
278 PERL_USE_SAFE_PUTENV USE_ITHREADS
279 USE_LARGE_FILES USE_PERLIO
282 Compiled at Jan 28 2009 15:26:59
284 This information is not available anywhere else, including C<%Config>,
285 but it is the information that is only known to the perl binary.
287 The extracted information is stored in 4 entries in the C<build> hash:
293 This is most likely the same as C$Config{osname}>, and was the name
294 known when perl was built. It might be different if perl was cross-compiled.
296 The default for this field, if it cannot be extracted, is to copy C<$Config{osname}>.
300 This is the time string for which the perl binary was compiled. The default
305 This is a hash with all the known defines as keys. The value is either 0,
306 which means unknown or unset, or 1, which means defined.
310 This is a list of optionally locally applied patches. Default is an empty list.
314 This include the flags that define the binary compatibility, like if
315 this perl was compiled for 64bitall (C<USE_64_BIT_ALL>), and basically is
319 By default this hash is only filled with the environment variables
320 out of %ENV that start with C<PERL>, but you can pass the C<env> option
321 to myconfig to get more
323 my $conf = Config::Perl::V::myconfig ({ env => qr/^ORACLE/ });
324 my $conf = Config::Perl::V::myconfig ([ env => qr/^ORACLE/ ]);
328 This hash is filled with the variables that C<perl -V> fils it's report
329 with, and it has the same variables that C<Config::myconfig> returns
334 This is the list of default @INC.
340 This module was written to be able to return the configuration for the
341 currently used perl as deeply as needed for the CPANTESTERS framework.
342 Up until now they used the output of myconfig as a single text blob,
343 and so it was missing the vital binary characteristics of the running
344 perl and the optional applied patches.
348 Please feedback what is wrong
352 * Implement retrieval functions/methods
354 * Include the perl -V parse block from Andreas
358 H.Merijn Brand <h.m.brand@xs4all.nl>
360 =head1 COPYRIGHT AND LICENSE
362 Copyright (C) 1999-2009 H.Merijn Brand
364 This library is free software; you can redistribute it and/or modify
365 it under the same terms as Perl itself.