This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
f565da0e0b22a1fbb03ff948763994a95dcd5c94
[perl5.git] / lib / Module / CoreList / bin / corelist
1 #!/usr/bin/perl
2
3 =head1 NAME
4
5 corelist - a commandline frontend to Module::CoreList
6
7 =head1 DESCRIPTION
8
9 See L<Module::CoreList> for one.
10
11 =head1 SYNOPSIS
12
13     corelist [-a] [ Modulename [ version ]] ...
14     corelist [-v [ version ]]
15
16 =head1 OPTIONS
17
18 =over
19
20 =item -a modulename
21
22     corelist -a utf8
23
24     utf8  was first released with perl 5.006
25       5.006      undef
26       5.006001   undef
27       5.006002   undef
28       5.007003   1.00
29       5.008      1.00
30       5.008001   1.02
31       5.008002   1.02
32       5.008003   1.02
33       5.008004   1.03
34       5.008005   1.04
35       5.008006   1.04
36       5.008007   1.05
37       5.008008   1.06
38       5.009      1.02
39       5.009001   1.02
40       5.009002   1.04
41       5.009003   1.06
42
43 =item -? or -help
44
45 help! help! help! to see more help, try --man.
46
47 =item -man
48
49 all of the help
50
51 =item -v
52
53 lists all of the perl release versions we got the CoreList for.
54
55 If you pass a version argument (value of C<$]>, like 5.00503),
56 you get a list of all the modules and their respective versions.
57
58 =back
59
60 =cut
61
62 use Module::CoreList;
63 use Getopt::Long;
64 use Pod::Usage;
65 use strict;
66 use warnings;
67
68 my %Opts;
69
70 GetOptions(\%Opts, qw[ help|?! man! v|version:f a! ] );
71
72 pod2usage(1) if $Opts{help};
73 pod2usage(-verbose=>2) if $Opts{man};
74
75 if(exists $Opts{v} ){
76     if( $Opts{v} ) {
77         if( exists $Module::CoreList::version{$Opts{v}} ) {
78             print "\nThe following modules were in perl v$Opts{v} CORE\n";
79             print "$_ ", $Module::CoreList::version{$Opts{v}}{$_} || " ","\n"
80                 for sort keys %{$Module::CoreList::version{$Opts{v}}};
81             print "\n";
82         } else {
83             print "\nModule::CoreList has no info on perl v$Opts{v}\n\n";
84         }
85     } else {
86         print "\nModule::CoreList has info on the following perl versions:\n";
87         print "$_\n" for sort keys %Module::CoreList::version;
88         print "\n";
89     }
90 } elsif (@ARGV) {
91     while (@ARGV) {
92         my ($mod, $ver);
93         if ($ARGV[0] =~ /=/) {
94             ($mod, $ver) = split /=/, shift @ARGV;
95         } else {
96             $mod = shift @ARGV;
97             $ver = (@ARGV && $ARGV[0] =~ /^\d/) ? shift @ARGV : "";
98         }
99         module_version($mod,$ver);
100     }
101 } else {
102     pod2usage(0);
103 }
104
105 exit();
106
107 sub module_version {
108     my($mod,$ver) = @_;
109
110     $ver = "" unless defined $ver;
111
112     my $ret = Module::CoreList->first_release(@_);
113     my $msg = "$mod $ver";
114
115     if( defined $ret ) {
116         $msg .= " was ";
117         $msg .= "first " unless $ver;
118         $msg .= "released with perl $ret"
119     } else {
120         $msg .= " was not in CORE (or so I think)";
121     }
122
123     print "\n",$msg,"\n";
124
125     if(defined $ret and exists $Opts{a} and $Opts{a}){
126         for my $v(
127             sort keys %Module::CoreList::version ){
128
129             printf "  %-10s %-10s\n",
130                 $v,
131                 $Module::CoreList::version{$v}{$mod}
132                     || 'undef'
133                     if exists $Module::CoreList::version{$v}{$mod};
134         }
135         print "\n";
136     }
137 }
138
139
140 =head1 EXAMPLES
141
142     $ corelist File::Spec
143
144     File::Spec  was first released with perl 5.005
145
146     $ corelist File::Spec 0.83
147
148     File::Spec 0.83 was released with perl 5.007003
149
150     $ corelist File::Spec 0.89
151
152     File::Spec 0.89 was not in CORE (or so I think)
153
154     $ corelist File::Spec::Aliens
155
156     File::Spec::Aliens  was not in CORE (or so I think)
157
158 =head1 COPYRIGHT
159
160 Copyright (c) 2002-2006 by D.H. aka PodMaster
161
162 Current maintainer : Rafael Garcia-Suarez E<lt>rgarciasuarez at mandriva dot
163 comE<gt>
164
165 This program is distributed under the same terms as perl itself.
166 See http://perl.org/ or http://cpan.org/ for more info on that.
167
168 =cut