1 package Module::CoreList::Utils;
5 use vars qw[$VERSION %utilities];
7 use Module::CoreList::TieHashDelta;
9 $VERSION = '5.20151120';
13 $perl = shift if eval { $perl->isa(__PACKAGE__) };
14 return unless $perl or exists $utilities{$perl};
15 return sort keys %{ $utilities{$perl} };
18 sub _released_order { # Sort helper, to make '?' sort after everything else
19 (substr($Module::CoreList::released{$a}, 0, 1) eq "?")
20 ? ((substr($Module::CoreList::released{$b}, 0, 1) eq "?")
23 : ((substr($Module::CoreList::released{$b}, 0, 1) eq "?")
25 : $Module::CoreList::released{$a} cmp $Module::CoreList::released{$b} )
28 sub first_release_raw {
30 $util = shift if eval { $util->isa(__PACKAGE__) };
31 #and scalar @_ and $_[0] =~ m#\A[a-zA-Z_][0-9a-zA-Z_]*(?:(::|')[0-9a-zA-Z_]+)*\z#;
35 ? grep { exists $utilities{$_}{ $util } &&
36 $utilities{$_}{ $util } ge $version } keys %utilities
37 : grep { exists $utilities{$_}{ $util } } keys %utilities;
39 return grep { exists $Module::CoreList::released{$_} } @perls;
42 sub first_release_by_date {
43 my @perls = &first_release_raw;
45 return (sort _released_order @perls)[0];
49 my @perls = &first_release_raw;
51 return (sort { $a cmp $b } @perls)[0];
55 my @perls = &removed_raw;
59 sub removed_from_by_date {
60 my @perls = sort _released_order &removed_raw;
66 $util = shift if eval { $util->isa(__PACKAGE__) };
67 return unless my @perls = sort { $a cmp $b } first_release_raw($util);
68 @perls = grep { exists $Module::CoreList::released{$_} } @perls;
69 my $last = pop @perls;
70 my @removed = grep { $_ > $last } sort { $a cmp $b } keys %utilities;
124 delta_from => 5.00307,
133 delta_from => 5.00405,
158 delta_from => 5.00504,
179 delta_from => 5.006002,
191 delta_from => 5.007003,
210 delta_from => 5.008009,
221 delta_from => 5.008001,
229 delta_from => 5.006001,
237 delta_from => 5.008002,
247 delta_from => 5.00503,
265 delta_from => 5.008003,
273 delta_from => 5.008004,
281 delta_from => 5.008005,
289 delta_from => 5.009001,
298 delta_from => 5.008006,
306 delta_from => 5.009002,
317 delta_from => 5.008007,
325 delta_from => 5.009003,
327 'config_data' => '1',
334 delta_from => 5.009004,
338 'cpanp-run-perl' => '1',
346 delta_from => 5.009005,
354 delta_from => 5.008008,
363 delta_from => 5.010000,
371 delta_from => 5.010001,
387 delta_from => 5.011001,
396 delta_from => 5.011002,
404 delta_from => 5.011003,
412 delta_from => 5.011004,
420 delta_from => 5.011005,
428 delta_from => 5.012005,
452 delta_from => 5.013001,
460 delta_from => 5.013002,
468 delta_from => 5.013003,
476 delta_from => 5.012001,
484 delta_from => 5.013004,
492 delta_from => 5.013005,
500 delta_from => 5.013006,
509 delta_from => 5.013007,
517 delta_from => 5.013008,
526 delta_from => 5.012002,
534 delta_from => 5.013009,
542 delta_from => 5.013010,
550 delta_from => 5.013011,
566 delta_from => 5.014004,
575 delta_from => 5.012003,
591 delta_from => 5.015001,
599 delta_from => 5.015002,
607 delta_from => 5.014001,
615 delta_from => 5.015003,
623 delta_from => 5.015004,
631 delta_from => 5.015005,
640 delta_from => 5.015006,
648 delta_from => 5.015007,
656 delta_from => 5.015008,
664 delta_from => 5.015009,
672 delta_from => 5.016003,
688 delta_from => 5.017001,
704 delta_from => 5.017002,
712 delta_from => 5.017003,
720 delta_from => 5.014002,
728 delta_from => 5.017004,
736 delta_from => 5.016001,
744 delta_from => 5.012004,
752 delta_from => 5.017005,
760 delta_from => 5.017006,
768 delta_from => 5.017007,
776 delta_from => 5.017008,
784 delta_from => 5.014003,
792 delta_from => 5.016002,
800 delta_from => 5.017009,
808 delta_from => 5.017010,
815 delta_from => 5.017011,
822 delta_from => 5.018000,
829 delta_from => 5.018001,
836 delta_from => 5.018000,
843 delta_from => 5.018000,
850 delta_from => 5.018000,
856 'cpanp-run-perl' => '1',
861 delta_from => 5.019000,
868 delta_from => 5.019001,
875 delta_from => 5.019002,
882 delta_from => 5.019003,
889 delta_from => 5.019004,
896 delta_from => 5.019005,
903 delta_from => 5.019006,
910 delta_from => 5.019007,
917 delta_from => 5.019008,
924 delta_from => 5.019009,
931 delta_from => 5.019010,
938 delta_from => 5.019011,
945 delta_from => 5.020000,
952 delta_from => 5.021000,
964 delta_from => 5.021001,
971 delta_from => 5.021002,
985 delta_from => 5.021003,
992 delta_from => 5.021004,
999 delta_from => 5.021005,
1006 delta_from => 5.021006,
1013 delta_from => 5.021007,
1020 delta_from => 5.020001,
1027 delta_from => 5.021008,
1035 delta_from => 5.021009,
1042 delta_from => 5.02101,
1049 delta_from => 5.021011,
1056 delta_from => 5.022000,
1063 delta_from => 5.023,
1070 delta_from => 5.023001,
1077 delta_from => 5.020002,
1084 delta_from => 5.023002,
1091 delta_from => 5.023003,
1098 delta_from => 5.023004,
1106 for my $version (sort { $a <=> $b } keys %delta) {
1107 my $data = $delta{$version};
1109 tie %{$utilities{$version}}, 'Module::CoreList::TieHashDelta',
1110 $data->{changed}, $data->{removed},
1111 $data->{delta_from} ? $utilities{$data->{delta_from}} : undef;
1114 # Create aliases with trailing zeros for $] use
1116 $utilities{'5.000'} = $utilities{5};
1118 _create_aliases(\%utilities);
1120 sub _create_aliases {
1123 for my $version (keys %$hash) {
1124 next unless $version >= 5.010;
1126 my $padded = sprintf "%0.6f", $version;
1128 # If the version in string form isn't the same as the numeric version,
1130 if ($padded ne $version && $version == $padded) {
1131 $hash->{$padded} = $hash->{$version};
1142 Module::CoreList::Utils - what utilities shipped with versions of perl
1146 use Module::CoreList::Utils;
1148 print $Module::CoreList::Utils::utilities{5.009003}{ptar}; # prints 1
1150 print Module::CoreList::Utils->first_release('corelist'); # prints 5.008009
1151 print Module::CoreList::Utils->first_release_by_date('corelist'); # prints 5.009002
1155 Module::CoreList::Utils provides information on which core and dual-life utilities shipped
1156 with each version of L<perl>.
1158 It provides a number of mechanisms for querying this information.
1160 There is a functional programming API available for programmers to query
1163 Programmers may also query the contained hash structure to find relevant
1166 =head1 FUNCTIONS API
1168 These are the functions that are available, they may either be called as functions or class methods:
1170 Module::CoreList::Utils::first_release('corelist'); # as a function
1172 Module::CoreList::Utils->first_release('corelist'); # class method
1178 Requires a perl version as an argument, returns a list of utilities that shipped with
1179 that version of perl, or undef/empty list if that perl doesn't exist.
1181 =item C<first_release( UTILITY )>
1183 Requires a UTILITY name as an argument, returns the perl version when that utility first
1184 appeared in core as ordered by perl version number or undef ( in scalar context )
1185 or an empty list ( in list context ) if that utility is not in core.
1187 =item C<first_release_by_date( UTILITY )>
1189 Requires a UTILITY name as an argument, returns the perl version when that utility first
1190 appeared in core as ordered by release date or undef ( in scalar context )
1191 or an empty list ( in list context ) if that utility is not in core.
1193 =item C<removed_from( UTILITY )>
1195 Takes a UTILITY name as an argument, returns the first perl version where that utility
1196 was removed from core. Returns undef if the given utility was never in core or remains
1199 =item C<removed_from_by_date( UTILITY )>
1201 Takes a UTILITY name as an argument, returns the first perl version by release date where that
1202 utility was removed from core. Returns undef if the given utility was never in core or remains
1207 =head1 DATA STRUCTURES
1209 These are the hash data structures that are available:
1213 =item C<%Module::CoreList::Utils::utilities>
1215 A hash of hashes that is keyed on perl version as indicated
1216 in $]. The second level hash is utility / defined pairs.
1222 Chris C<BinGOs> Williams <chris@bingosnet.co.uk>
1224 Currently maintained by the perl 5 porters E<lt>perl5-porters@perl.orgE<gt>.
1226 This module is the result of archaeology undertaken during QA Hackathon
1227 in Lancaster, April 2013.
1231 Copyright (C) 2013 Chris Williams. All Rights Reserved.
1233 This module is free software; you can redistribute it and/or modify it
1234 under the same terms as Perl itself.
1238 L<corelist>, L<Module::CoreList>, L<perl>, L<http://perlpunks.de/corelist>