1 package Module::CoreList::Utils;
5 use vars qw[$VERSION %utilities];
8 $VERSION = '5.20170320';
12 $perl = shift if eval { $perl->isa(__PACKAGE__) };
13 return unless $perl or exists $utilities{$perl};
14 return sort keys %{ $utilities{$perl} };
17 sub _released_order { # Sort helper, to make '?' sort after everything else
18 (substr($Module::CoreList::released{$a}, 0, 1) eq "?")
19 ? ((substr($Module::CoreList::released{$b}, 0, 1) eq "?")
22 : ((substr($Module::CoreList::released{$b}, 0, 1) eq "?")
24 : $Module::CoreList::released{$a} cmp $Module::CoreList::released{$b} )
27 sub first_release_raw {
29 $util = shift if eval { $util->isa(__PACKAGE__) };
30 #and scalar @_ and $_[0] =~ m#\A[a-zA-Z_][0-9a-zA-Z_]*(?:(::|')[0-9a-zA-Z_]+)*\z#;
34 ? grep { exists $utilities{$_}{ $util } &&
35 $utilities{$_}{ $util } ge $version } keys %utilities
36 : grep { exists $utilities{$_}{ $util } } keys %utilities;
38 return grep { exists $Module::CoreList::released{$_} } @perls;
41 sub first_release_by_date {
42 my @perls = &first_release_raw;
44 return (sort _released_order @perls)[0];
48 my @perls = &first_release_raw;
50 return (sort { $a cmp $b } @perls)[0];
54 my @perls = &removed_raw;
58 sub removed_from_by_date {
59 my @perls = sort _released_order &removed_raw;
65 $util = shift if eval { $util->isa(__PACKAGE__) };
66 return unless my @perls = sort { $a cmp $b } first_release_raw($util);
67 @perls = grep { exists $Module::CoreList::released{$_} } @perls;
68 my $last = pop @perls;
69 my @removed = grep { $_ > $last } sort { $a cmp $b } keys %utilities;
123 delta_from => 5.00307,
132 delta_from => 5.00405,
157 delta_from => 5.00504,
178 delta_from => 5.006002,
190 delta_from => 5.007003,
209 delta_from => 5.008009,
220 delta_from => 5.008001,
228 delta_from => 5.006001,
236 delta_from => 5.008002,
246 delta_from => 5.00503,
264 delta_from => 5.008003,
272 delta_from => 5.008004,
280 delta_from => 5.008005,
288 delta_from => 5.009001,
297 delta_from => 5.008006,
305 delta_from => 5.009002,
316 delta_from => 5.008007,
324 delta_from => 5.009003,
326 'config_data' => '1',
333 delta_from => 5.009004,
337 'cpanp-run-perl' => '1',
345 delta_from => 5.009005,
353 delta_from => 5.008008,
362 delta_from => 5.010000,
370 delta_from => 5.010001,
386 delta_from => 5.011001,
395 delta_from => 5.011002,
403 delta_from => 5.011003,
411 delta_from => 5.011004,
419 delta_from => 5.011005,
427 delta_from => 5.012005,
451 delta_from => 5.013001,
459 delta_from => 5.013002,
467 delta_from => 5.013003,
475 delta_from => 5.012001,
483 delta_from => 5.013004,
491 delta_from => 5.013005,
499 delta_from => 5.013006,
508 delta_from => 5.013007,
516 delta_from => 5.013008,
525 delta_from => 5.012002,
533 delta_from => 5.013009,
541 delta_from => 5.013010,
549 delta_from => 5.013011,
565 delta_from => 5.014004,
574 delta_from => 5.012003,
590 delta_from => 5.015001,
598 delta_from => 5.015002,
606 delta_from => 5.014001,
614 delta_from => 5.015003,
622 delta_from => 5.015004,
630 delta_from => 5.015005,
639 delta_from => 5.015006,
647 delta_from => 5.015007,
655 delta_from => 5.015008,
663 delta_from => 5.015009,
671 delta_from => 5.016003,
687 delta_from => 5.017001,
703 delta_from => 5.017002,
711 delta_from => 5.017003,
719 delta_from => 5.014002,
727 delta_from => 5.017004,
735 delta_from => 5.016001,
743 delta_from => 5.012004,
751 delta_from => 5.017005,
759 delta_from => 5.017006,
767 delta_from => 5.017007,
775 delta_from => 5.017008,
783 delta_from => 5.014003,
791 delta_from => 5.016002,
799 delta_from => 5.017009,
807 delta_from => 5.017010,
814 delta_from => 5.017011,
821 delta_from => 5.018000,
828 delta_from => 5.018001,
835 delta_from => 5.018000,
842 delta_from => 5.018000,
849 delta_from => 5.018000,
855 'cpanp-run-perl' => '1',
860 delta_from => 5.019000,
867 delta_from => 5.019001,
874 delta_from => 5.019002,
881 delta_from => 5.019003,
888 delta_from => 5.019004,
895 delta_from => 5.019005,
902 delta_from => 5.019006,
909 delta_from => 5.019007,
916 delta_from => 5.019008,
923 delta_from => 5.019009,
930 delta_from => 5.019010,
937 delta_from => 5.019011,
944 delta_from => 5.020000,
951 delta_from => 5.021000,
963 delta_from => 5.021001,
970 delta_from => 5.021002,
984 delta_from => 5.021003,
991 delta_from => 5.021004,
998 delta_from => 5.021005,
1005 delta_from => 5.021006,
1012 delta_from => 5.021007,
1019 delta_from => 5.020001,
1026 delta_from => 5.021008,
1034 delta_from => 5.021009,
1041 delta_from => 5.02101,
1048 delta_from => 5.021011,
1055 delta_from => 5.022000,
1062 delta_from => 5.023,
1069 delta_from => 5.023001,
1076 delta_from => 5.020002,
1083 delta_from => 5.023002,
1090 delta_from => 5.023003,
1097 delta_from => 5.023004,
1104 delta_from => 5.022,
1111 delta_from => 5.023005,
1118 delta_from => 5.023006,
1125 delta_from => 5.023007,
1132 delta_from => 5.023008,
1139 delta_from => 5.022001,
1146 delta_from => 5.023009,
1153 delta_from => 5.024000,
1160 delta_from => 5.025000,
1167 delta_from => 5.025001,
1174 delta_from => 5.025002,
1181 delta_from => 5.025003,
1188 delta_from => 5.025004,
1195 delta_from => 5.025005,
1202 delta_from => 5.025006,
1209 delta_from => 5.025007,
1216 delta_from => 5.022002,
1223 delta_from => 5.024000,
1230 delta_from => 5.025008,
1239 delta_from => 5.025009,
1246 delta_from => 5.025010,
1254 %utilities = Module::CoreList::_undelta(\%delta);
1256 # Create aliases with trailing zeros for $] use
1258 $utilities{'5.000'} = $utilities{5};
1260 _create_aliases(\%utilities);
1262 sub _create_aliases {
1265 for my $version (keys %$hash) {
1266 next unless $version >= 5.010;
1268 my $padded = sprintf "%0.6f", $version;
1270 # If the version in string form isn't the same as the numeric version,
1272 if ($padded ne $version && $version == $padded) {
1273 $hash->{$padded} = $hash->{$version};
1284 Module::CoreList::Utils - what utilities shipped with versions of perl
1288 use Module::CoreList::Utils;
1290 print $Module::CoreList::Utils::utilities{5.009003}{ptar}; # prints 1
1292 print Module::CoreList::Utils->first_release('corelist');
1295 print Module::CoreList::Utils->first_release_by_date('corelist');
1300 Module::CoreList::Utils provides information on which core and dual-life utilities shipped
1301 with each version of L<perl>.
1303 It provides a number of mechanisms for querying this information.
1305 There is a functional programming API available for programmers to query
1308 Programmers may also query the contained hash structure to find relevant
1311 =head1 FUNCTIONS API
1313 These are the functions that are available, they may either be called as functions or class methods:
1315 Module::CoreList::Utils::first_release('corelist'); # as a function
1317 Module::CoreList::Utils->first_release('corelist'); # class method
1323 Requires a perl version as an argument, returns a list of utilities that shipped with
1324 that version of perl, or undef/empty list if that perl doesn't exist.
1326 =item C<first_release( UTILITY )>
1328 Requires a UTILITY name as an argument, returns the perl version when that utility first
1329 appeared in core as ordered by perl version number or undef ( in scalar context )
1330 or an empty list ( in list context ) if that utility is not in core.
1332 =item C<first_release_by_date( UTILITY )>
1334 Requires a UTILITY name as an argument, returns the perl version when that utility first
1335 appeared in core as ordered by release date or undef ( in scalar context )
1336 or an empty list ( in list context ) if that utility is not in core.
1338 =item C<removed_from( UTILITY )>
1340 Takes a UTILITY name as an argument, returns the first perl version where that utility
1341 was removed from core. Returns undef if the given utility was never in core or remains
1344 =item C<removed_from_by_date( UTILITY )>
1346 Takes a UTILITY name as an argument, returns the first perl version by release date where that
1347 utility was removed from core. Returns undef if the given utility was never in core or remains
1352 =head1 DATA STRUCTURES
1354 These are the hash data structures that are available:
1358 =item C<%Module::CoreList::Utils::utilities>
1360 A hash of hashes that is keyed on perl version as indicated
1361 in $]. The second level hash is utility / defined pairs.
1367 Chris C<BinGOs> Williams <chris@bingosnet.co.uk>
1369 Currently maintained by the perl 5 porters E<lt>perl5-porters@perl.orgE<gt>.
1371 This module is the result of archaeology undertaken during QA Hackathon
1372 in Lancaster, April 2013.
1376 Copyright (C) 2013 Chris Williams. All Rights Reserved.
1378 This module is free software; you can redistribute it and/or modify it
1379 under the same terms as Perl itself.
1383 L<corelist>, L<Module::CoreList>, L<perl>, L<http://perlpunks.de/corelist>