From 538c109039d3e3bdf34e6b3d4d521e4418a10d53 Mon Sep 17 00:00:00 2001 From: "H.Merijn Brand" Date: Mon, 30 Mar 2009 13:47:50 +0200 Subject: [PATCH] add summary () --- V.pm | 33 +++++++++++++++++++++++++++++---- examples/show-v.pl | 5 ++++- 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/V.pm b/V.pm index cb9d710..ef2d43d 100644 --- a/V.pm +++ b/V.pm @@ -221,6 +221,25 @@ sub plv2hash }); } # plv2hash +sub summary +{ + my $conf = shift; + ref $conf eq "HASH" && + exists $conf->{config} && exists $conf->{build} or return; + + my %info = map { + exists $conf->{config}{$_} ? ( $_ => $conf->{config}{$_} ) : () } + qw( archname osname osvers revision patchlevel subversion version + cc ccversion gccversion config_args inc_version_list + d_longdbl d_longlong use64bitall use64bitint useithreads + uselongdouble usemultiplicity usemymalloc useperlio useshrplib + doublesize intsize ivsize nvsize longdblsize longlongsize lseeksize + ); + $info{$_}++ for grep { $conf->{build}{options}{$_} } keys %{$conf->{build}{options}}; + + return \%info; + } # summary + sub myconfig { my $args = shift; @@ -274,14 +293,20 @@ Config::Perl::V - Structured data retreival of perl -V output =head1 DESCRIPTION -=head2 myconfig () +=head2 $conf = myconfig () This function will collect the data decribed in L below, +and return that as a hash reference. It optionally accepts an option to +include more entries from %ENV. See L below. + +=head2 $conf = plv2hash ($text [, ...]) + +Convert a sole 'perl -V' text block, or list of lines, to a complete +myconfig hash. All unknown entries are defaulted. -=head2 plv2hash () +=head2 $info = summary ($conf) -Convert a sole 'perl -V' text block to a complete myconfig hash. -All unknown entries are defaulted. +Return an arbitrary selection of the information. =head2 The hash structure diff --git a/examples/show-v.pl b/examples/show-v.pl index 4823a07..2fac597 100755 --- a/examples/show-v.pl +++ b/examples/show-v.pl @@ -6,4 +6,7 @@ use warnings; use Data::Peek; use Config::Perl::V; -DDumper Config::Perl::V::myconfig [ @ARGV ]; +my $conf = Config::Perl::V::myconfig [ @ARGV ]; +DDumper $conf; + +DDumper Config::Perl::V::summary $conf; -- 2.11.4.GIT