2006-07-05 23:59:39 +08:00
|
|
|
#!/usr/bin/perl
|
|
|
|
|
|
|
|
my %data = ();
|
|
|
|
my %code = ();
|
|
|
|
|
|
|
|
my @out = ();
|
|
|
|
|
|
|
|
my $fn = $ARGV[0];
|
|
|
|
|
|
|
|
while (<>) {
|
|
|
|
push(@out, $_);
|
|
|
|
/^\s*exports/i and last;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (<>) {
|
|
|
|
my $key;
|
|
|
|
$arr = /\sDATA\s*$/o ? \%data : \%code;
|
|
|
|
$_ =~ s/^\s+//;
|
|
|
|
my $key = (split(' ', $_))[0];
|
2006-07-06 00:06:50 +08:00
|
|
|
substr($key, 0, 1) = '' while $key =~ /^_/o;
|
2006-07-05 23:59:39 +08:00
|
|
|
chomp $key;
|
|
|
|
$arr->{$key}->{$_} = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
for my $k (sort keys %data) {
|
|
|
|
push(@out, sort {$b cmp $a} keys %{$data{$k}});
|
|
|
|
}
|
|
|
|
|
|
|
|
for my $k (sort keys %code) {
|
|
|
|
push(@out, sort {$b cmp $a} keys %{$code{$k}});
|
|
|
|
}
|
|
|
|
|
|
|
|
open(R, '>', $fn);
|
|
|
|
print R @out;
|
|
|
|
close R;
|