Skip to content

Commit c57c8d0

Browse files
committed
add listing of the words
1 parent cdb1cbb commit c57c8d0

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

index.pl

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
#!/usr/bin/env perl6
22
use v6;
33

4-
sub MAIN() {
5-
my $outfile = "index.ini";
4+
my $index_file = "index.data";
5+
multi sub MAIN() {
6+
say "Usage: $*PROGRAM_NAME index to index the docs";
7+
say "Usage: $*PROGRAM_NAME list to list the names";
8+
}
9+
10+
multi sub MAIN('index') {
611
my %words;
712
for dir('lib') -> $file {
813
my $pod = substr($file.Str, 0 , $file.Str.chars -4);
@@ -20,8 +25,21 @@ ()
2025
}
2126
}
2227
}
23-
my $out = open('index.data', :w);
28+
my $out = open($index_file, :w);
2429
$out.print(%words.perl);
2530
$out.close;
2631
}
32+
multi sub MAIN('list') {
33+
if $index_file.IO ~~ :e {
34+
my %data = eval slurp $index_file;
35+
for %data.keys.sort -> $name {
36+
say $name
37+
# my $newdoc = %data{$docee}[0][0] ~ "." ~ %data{$docee}[0][1];
38+
# return MAIN($newdoc, :f);
39+
}
40+
} else {
41+
say "First run $*PROGRAM_NAME index to create the index";
42+
exit;
43+
}
44+
}
2745

0 commit comments

Comments
 (0)