1 package Module::CoreList::Utils;
5 use vars qw[$VERSION %utilities];
7 use Module::CoreList::TieHashDelta;
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.018000,
825 'cpanp-run-perl' => '1',
830 delta_from => 5.019000,
837 delta_from => 5.019001,
844 delta_from => 5.019002,
851 delta_from => 5.019003,
858 delta_from => 5.019004,
865 delta_from => 5.019005,
872 delta_from => 5.019006,
879 delta_from => 5.019007,
887 for my $version (sort { $a <=> $b } keys %delta) {
888 my $data = $delta{$version};
890 tie %{$utilities{$version}}, 'Module::CoreList::TieHashDelta',
891 $data->{changed}, $data->{removed},
892 $data->{delta_from} ? $utilities{$data->{delta_from}} : undef;
895 # Create aliases with trailing zeros for $] use
897 $utilities{'5.000'} = $utilities{5};
899 _create_aliases(\%utilities);
901 sub _create_aliases {
904 for my $version (keys %$hash) {
905 next unless $version >= 5.010;
907 my $padded = sprintf "%0.6f", $version;
909 # If the version in string form isn't the same as the numeric version,
911 if ($padded ne $version && $version == $padded) {
912 $hash->{$padded} = $hash->{$version};
923 Module::CoreList::Utils - what utilities shipped with versions of perl
927 use Module::CoreList::Utils;
929 print $Module::CoreList::Utils::utilities{5.009003}{ptar}; # prints 1
931 print Module::CoreList::Utils->first_release('corelist'); # prints 5.008009
932 print Module::CoreList::Utils->first_release_by_date('corelist'); # prints 5.009002
936 Module::CoreList::Utils provides information on which core and dual-life utilities shipped
937 with each version of L<perl>.
939 It provides a number of mechanisms for querying this information.
941 There is a functional programming API available for programmers to query
944 Programmers may also query the contained hash structure to find relevant
949 These are the functions that are available, they may either be called as functions or class methods:
951 Module::CoreList::Utils::first_release('corelist'); # as a function
953 Module::CoreList::Utils->first_release('corelist'); # class method
959 Requires a perl version as an argument, returns a list of utilities that shipped with
960 that version of perl, or undef/empty list if that perl doesn't exist.
962 =item C<first_release( UTILITY )>
964 Requires a UTILITY name as an argument, returns the perl version when that utility first
965 appeared in core as ordered by perl version number or undef ( in scalar context )
966 or an empty list ( in list context ) if that utility is not in core.
968 =item C<first_release_by_date( UTILITY )>
970 Requires a UTILITY name as an argument, returns the perl version when that utility first
971 appeared in core as ordered by release date or undef ( in scalar context )
972 or an empty list ( in list context ) if that utility is not in core.
974 =item C<removed_from( UTILITY )>
976 Takes a UTILITY name as an argument, returns the first perl version where that utility
977 was removed from core. Returns undef if the given utility was never in core or remains
980 =item C<removed_from_by_date( UTILITY )>
982 Takes a UTILITY name as an argument, returns the first perl version by release date where that
983 utility was removed from core. Returns undef if the given utility was never in core or remains
988 =head1 DATA STRUCTURES
990 These are the hash data structures that are available:
994 =item C<%Module::CoreList::Utils::utilities>
996 A hash of hashes that is keyed on perl version as indicated
997 in $]. The second level hash is utility / defined pairs.
1003 Chris C<BinGOs> Williams <chris@bingosnet.co.uk>
1005 Currently maintained by the perl 5 porters E<lt>perl5-porters@perl.orgE<gt>.
1007 This module is the result of archaeology undertaken during QA Hackathon
1008 in Lancaster, April 2013.
1012 Copyright (C) 2013 Chris Williams. All Rights Reserved.
1014 This module is free software; you can redistribute it and/or modify it
1015 under the same terms as Perl itself.
1019 L<corelist>, L<Module::CoreList>, L<perl>, L<http://perlpunks.de/corelist>