45 |
return $t; |
return $t; |
46 |
} |
} |
47 |
|
|
48 |
|
my @lines; |
49 |
|
|
50 |
while(<STDIN>) { |
while(<STDIN>) { |
51 |
chomp; |
chomp; |
52 |
|
|
55 |
next; |
next; |
56 |
} |
} |
57 |
|
|
58 |
|
# remove leading spaces (which are ignored if source list was |
59 |
|
# sorted using locale) |
60 |
|
s/^\s+//; |
61 |
|
|
62 |
|
push @lines, $_; |
63 |
|
} |
64 |
|
|
65 |
|
# spaces will be ignored when sorting using locale. That's why we have |
66 |
|
# cache of lines with spaces replaced by exclamation mark (!) so that |
67 |
|
# sort order is strict and not dictionary. For more info, see: |
68 |
|
# http://archives.postgresql.org/pgsql-sql/2002-04/msg00266.php |
69 |
|
# http://groups.google.com/groups?selm=handler.82819.D82819.99045085113033.ackdone%40bugs.debian.org&output=gplain |
70 |
|
|
71 |
|
my %locale_space_fix; |
72 |
|
|
73 |
|
foreach (sort { |
74 |
|
unless($locale_space_fix{$a}) { |
75 |
|
my $tmp = $a; |
76 |
|
$tmp =~ s/ /!/g; |
77 |
|
$locale_space_fix{$a} = lc($tmp); |
78 |
|
} |
79 |
|
unless($locale_space_fix{$b}) { |
80 |
|
my $tmp = $b; |
81 |
|
$tmp =~ s/ /!/g; |
82 |
|
$locale_space_fix{$b} = lc($tmp); |
83 |
|
} |
84 |
|
$locale_space_fix{$a} cmp $locale_space_fix{$b}; |
85 |
|
} @lines) { |
86 |
|
|
87 |
my @data = split(/\t+/,$_); |
my @data = split(/\t+/,$_); |
88 |
|
|
89 |
my $headline = shift @data || die "need at least headline!"; |
my $headline = shift @data || die "need at least headline!"; |