7 Porting/manifest_lib.pl - functions for managing manifests
11 require './Porting/manifest_lib.pl';
15 This file makes available one function, C<sort_manifest()>.
17 =head2 C<sort_manifest>
19 Treats its arguments as (chomped) lines from a MANIFEST file, and returns that
20 listed sorted appropriately.
24 # Try to get a sane sort. case insensitive, more or less
25 # sorted such that path components are compared independently,
26 # and so that lib/Foo/Bar sorts before lib/Foo-Alpha/Baz
27 # and so that lib/Foo/Bar.pm sorts before lib/Foo/Bar/Alpha.pm
28 # and so that configure and Configure sort together.
31 # case insensitive sorting of directory components independently.
32 map { $_->[0] } # extract the full line
34 $a->[1] cmp $b->[1] || # sort in order of munged filename
35 $a->[0] cmp $b->[0] # then by the exact text in full line
38 # split out the filename and the description
39 my ($f) = split /\s+/, $_, 2;
40 # lc the filename so Configure and configure sort together in the list
41 my $m= lc $f; # $m for munged
42 # replace slashes by nulls, this makes short directory names sort before
43 # longer ones, such as "foo/" sorting before "foo-bar/"
45 # replace the extension (only one) by null null extension.
46 # this puts any foo/blah.ext before any files in foo/blah/
47 $m =~ s{(?<!\A)(\.[^.]+\z)}{\0\0$1};
49 # return the original string, and the munged filename
56 # ex: set ts=8 sts=4 sw=4 et: