1 package Module::CoreList::Utils;
5 use vars qw[$VERSION %utilities];
7 use Module::CoreList::TieHashDelta;
9 $VERSION = '5.20150220';
13 $perl = shift if eval { $perl->isa(__PACKAGE__) };
14 return unless $perl or exists $utilities{$perl};
15 return sort keys %{ $utilities{$perl} };
18 sub first_release_raw {
20 $util = shift if eval { $util->isa(__PACKAGE__) };
21 #and scalar @_ and $_[0] =~ m#\A[a-zA-Z_][0-9a-zA-Z_]*(?:(::|')[0-9a-zA-Z_]+)*\z#;
25 ? grep { exists $utilities{$_}{ $util } &&
26 $utilities{$_}{ $util } ge $version } keys %utilities
27 : grep { exists $utilities{$_}{ $util } } keys %utilities;
29 return grep { exists $Module::CoreList::released{$_} } @perls;
32 sub first_release_by_date {
33 my @perls = &first_release_raw;
35 return (sort { $Module::CoreList::released{$a} cmp $Module::CoreList::released{$b} } @perls)[0];
39 my @perls = &first_release_raw;
41 return (sort { $a cmp $b } @perls)[0];
45 my @perls = &removed_raw;
49 sub removed_from_by_date {
50 my @perls = sort { $Module::CoreList::released{$a} cmp $Module::CoreList::released{$b} } &removed_raw;
56 $util = shift if eval { $util->isa(__PACKAGE__) };
57 return unless my @perls = sort { $a cmp $b } first_release_raw($util);
58 @perls = grep { exists $Module::CoreList::released{$_} } @perls;
59 my $last = pop @perls;
60 my @removed = grep { $_ > $last } sort { $a cmp $b } keys %utilities;
114 delta_from => 5.00307,
123 delta_from => 5.00405,
148 delta_from => 5.00504,
169 delta_from => 5.006002,
181 delta_from => 5.007003,
200 delta_from => 5.008009,
211 delta_from => 5.008001,
219 delta_from => 5.006001,
227 delta_from => 5.008002,
237 delta_from => 5.00503,
255 delta_from => 5.008003,
263 delta_from => 5.008004,
271 delta_from => 5.008005,
279 delta_from => 5.009001,
288 delta_from => 5.008006,
296 delta_from => 5.009002,
307 delta_from => 5.008007,
315 delta_from => 5.009003,
317 'config_data' => '1',
324 delta_from => 5.009004,
328 'cpanp-run-perl' => '1',
336 delta_from => 5.009005,
344 delta_from => 5.008008,
353 delta_from => 5.010000,
361 delta_from => 5.010001,
377 delta_from => 5.011001,
386 delta_from => 5.011002,
394 delta_from => 5.011003,
402 delta_from => 5.011004,
410 delta_from => 5.011005,
418 delta_from => 5.012005,
442 delta_from => 5.013001,
450 delta_from => 5.013002,
458 delta_from => 5.013003,
466 delta_from => 5.012001,
474 delta_from => 5.013004,
482 delta_from => 5.013005,
490 delta_from => 5.013006,
499 delta_from => 5.013007,
507 delta_from => 5.013008,
516 delta_from => 5.012002,
524 delta_from => 5.013009,
532 delta_from => 5.013010,
540 delta_from => 5.013011,
556 delta_from => 5.014004,
565 delta_from => 5.012003,
581 delta_from => 5.015001,
589 delta_from => 5.015002,
597 delta_from => 5.014001,
605 delta_from => 5.015003,
613 delta_from => 5.015004,
621 delta_from => 5.015005,
630 delta_from => 5.015006,
638 delta_from => 5.015007,
646 delta_from => 5.015008,
654 delta_from => 5.015009,
662 delta_from => 5.016003,
678 delta_from => 5.017001,
694 delta_from => 5.017002,
702 delta_from => 5.017003,
710 delta_from => 5.014002,
718 delta_from => 5.017004,
726 delta_from => 5.016001,
734 delta_from => 5.012004,
742 delta_from => 5.017005,
750 delta_from => 5.017006,
758 delta_from => 5.017007,
766 delta_from => 5.017008,
774 delta_from => 5.014003,
782 delta_from => 5.016002,
790 delta_from => 5.017009,
798 delta_from => 5.017010,
805 delta_from => 5.017011,
812 delta_from => 5.018000,
819 delta_from => 5.018001,
826 delta_from => 5.018000,
833 delta_from => 5.018000,
840 delta_from => 5.018000,
846 'cpanp-run-perl' => '1',
851 delta_from => 5.019000,
858 delta_from => 5.019001,
865 delta_from => 5.019002,
872 delta_from => 5.019003,
879 delta_from => 5.019004,
886 delta_from => 5.019005,
893 delta_from => 5.019006,
900 delta_from => 5.019007,
907 delta_from => 5.019008,
914 delta_from => 5.019009,
921 delta_from => 5.019010,
928 delta_from => 5.019011,
935 delta_from => 5.020000,
942 delta_from => 5.021000,
954 delta_from => 5.021001,
961 delta_from => 5.021002,
975 delta_from => 5.021003,
982 delta_from => 5.021004,
989 delta_from => 5.021005,
996 delta_from => 5.021006,
1003 delta_from => 5.021007,
1010 delta_from => 5.020001,
1017 delta_from => 5.021008,
1025 delta_from => 5.021009,
1033 for my $version (sort { $a <=> $b } keys %delta) {
1034 my $data = $delta{$version};
1036 tie %{$utilities{$version}}, 'Module::CoreList::TieHashDelta',
1037 $data->{changed}, $data->{removed},
1038 $data->{delta_from} ? $utilities{$data->{delta_from}} : undef;
1041 # Create aliases with trailing zeros for $] use
1043 $utilities{'5.000'} = $utilities{5};
1045 _create_aliases(\%utilities);
1047 sub _create_aliases {
1050 for my $version (keys %$hash) {
1051 next unless $version >= 5.010;
1053 my $padded = sprintf "%0.6f", $version;
1055 # If the version in string form isn't the same as the numeric version,
1057 if ($padded ne $version && $version == $padded) {
1058 $hash->{$padded} = $hash->{$version};
1069 Module::CoreList::Utils - what utilities shipped with versions of perl
1073 use Module::CoreList::Utils;
1075 print $Module::CoreList::Utils::utilities{5.009003}{ptar}; # prints 1
1077 print Module::CoreList::Utils->first_release('corelist'); # prints 5.008009
1078 print Module::CoreList::Utils->first_release_by_date('corelist'); # prints 5.009002
1082 Module::CoreList::Utils provides information on which core and dual-life utilities shipped
1083 with each version of L<perl>.
1085 It provides a number of mechanisms for querying this information.
1087 There is a functional programming API available for programmers to query
1090 Programmers may also query the contained hash structure to find relevant
1093 =head1 FUNCTIONS API
1095 These are the functions that are available, they may either be called as functions or class methods:
1097 Module::CoreList::Utils::first_release('corelist'); # as a function
1099 Module::CoreList::Utils->first_release('corelist'); # class method
1105 Requires a perl version as an argument, returns a list of utilities that shipped with
1106 that version of perl, or undef/empty list if that perl doesn't exist.
1108 =item C<first_release( UTILITY )>
1110 Requires a UTILITY name as an argument, returns the perl version when that utility first
1111 appeared in core as ordered by perl version number or undef ( in scalar context )
1112 or an empty list ( in list context ) if that utility is not in core.
1114 =item C<first_release_by_date( UTILITY )>
1116 Requires a UTILITY name as an argument, returns the perl version when that utility first
1117 appeared in core as ordered by release date or undef ( in scalar context )
1118 or an empty list ( in list context ) if that utility is not in core.
1120 =item C<removed_from( UTILITY )>
1122 Takes a UTILITY name as an argument, returns the first perl version where that utility
1123 was removed from core. Returns undef if the given utility was never in core or remains
1126 =item C<removed_from_by_date( UTILITY )>
1128 Takes a UTILITY name as an argument, returns the first perl version by release date where that
1129 utility was removed from core. Returns undef if the given utility was never in core or remains
1134 =head1 DATA STRUCTURES
1136 These are the hash data structures that are available:
1140 =item C<%Module::CoreList::Utils::utilities>
1142 A hash of hashes that is keyed on perl version as indicated
1143 in $]. The second level hash is utility / defined pairs.
1149 Chris C<BinGOs> Williams <chris@bingosnet.co.uk>
1151 Currently maintained by the perl 5 porters E<lt>perl5-porters@perl.orgE<gt>.
1153 This module is the result of archaeology undertaken during QA Hackathon
1154 in Lancaster, April 2013.
1158 Copyright (C) 2013 Chris Williams. All Rights Reserved.
1160 This module is free software; you can redistribute it and/or modify it
1161 under the same terms as Perl itself.
1165 L<corelist>, L<Module::CoreList>, L<perl>, L<http://perlpunks.de/corelist>