Hello,
I wanted to port WWWMAN to Linux, but it was too difficult and time
consuming, so I wrote a "light" version of WWWMAN in Perl.

In mime.conf should be:
file/*         >HTM|wwwman.pl $u>$2

What do you think about?
I have a lot of time.
Any wishes?

Witek
#!/usr/bin/perl
# wwwman.pl for Linux
# (C) 2001 Witold Filipczyk <[EMAIL PROTECTED]>

$ARGV[0] =~ /file(.*)/;
$rest = $1;
if ($rest =~ /(.*\/)(.*)/) {
        $dir = $1;
        $rest = $2;
}
$rest2 = $rest;
$rest2 =~ s/\./\\\./g;
$rest2 =~ s/\*/\.\*/g;

open LS, "ls -alF --color $dir|" or die;
print "<HTML><BODY><PRE>\n";
while (<LS>) {
        if (/^\e.*?m(.*?)\e(.*?)m(.*?)\e.*?m(.*)/) {
                $begin = $1;
                $nap = $3;
                $char = $4;
        }
        else {
                /^(.*?)\e(.*?)m(.*?)\e.*?m(.*)/;
                $begin = $1;
                $nap = $3;
                $char = $4;
        }
        if ($begin) {
                if ($char eq '/') {
                        if ($nap eq "..") {
                                $dir2 = $dir;
                                $dir2 =~ s/\/$//;
                                $dir2 =~ /(.*\/)/;
                                $file = $1 . $rest;
                                print "$begin<A HREF=\"$file";
                                print "\">$nap</A>\n";
                        }
                        elsif ($nap ne ".") {
                                $file = $dir . $nap . '/'. $rest;
                                print "$begin<A HREF=\"$file";
                                print "\">$nap</A>\n";
                        }
                }
                else {
                        if ($nap =~ /$rest2/) {
                                $file = $dir . $nap;
                                print "$begin<A HREF=\"$file";
                                print "\">$nap</A>\n";
                        }
                }
        }
}
print "</PRE></BODY></HTML>\n";
close LS;

Reply via email to