| 1 |
#!/usr/bin/env perl |
| 2 |
# Written by <[email protected]> |
| 3 |
#%DESC Show description of script's directory programs according to embedded #%DESC |
| 4 |
|
| 5 |
use strict; |
| 6 |
use warnings; |
| 7 |
|
| 8 |
(my $progdir = $0) =~ s,/[^/]+$,,; |
| 9 |
|
| 10 |
opendir(PROGDIR, $progdir) || die "$0: Cannor opendir '$progdir': $!"; |
| 11 |
(my @files = readdir(PROGDIR)) || die "$0: Cannor readdir '$progdir': $!"; |
| 12 |
chdir $progdir; |
| 13 |
|
| 14 |
FILE: foreach my $f (@files) { |
| 15 |
next if $f =~ /^\./ || -d $f; |
| 16 |
open(PROGF, $f) || die "$0: Cannor open '$f': $!"; |
| 17 |
foreach (<PROGF>) { |
| 18 |
if (s/^#%DESC\s+//) { |
| 19 |
printf "%-20s %s", $f, $_; |
| 20 |
next FILE; |
| 21 |
} |
| 22 |
} |
| 23 |
printf "%-20s *** No description ***\n", $f; |
| 24 |
} |