D
Dan Jacobson
Say, does this working simple web site mapper (vs. Eric Raymond's
extra large version) have any stuffing hanging out that perl novice me
ought to fix? Say, how does one do '/bin/sh -e' in perl? Would
rewriting it in python be as easy? Does perl have an internal "ls"
that could be called as easy? File::Find couldn't give me the ls -R
order I prefer I suppose. Goal: to use even less lines of code.
use strict;
require HTML::HeadParser;
my $dir=<~/mywebsite>; #where files are on my computer
my $name="Bob Blobkowski";
my $url='http://blobkowski.org/';
chdir $dir||die;
print <<EOF;
<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd"><HTML><TITLE>$name\'s site map</TITLE>
</HEAD><BODY><H1>$name\'s site map</H1>\n<P><A href="$url">$url</A> as of
EOF
system "date"; print '</P><HR><PRE>';
my $p = HTML::HeadParser->new; my $d;
open LS, "ls -R|"||die;
while(<LS>){ #order nicer than find(1)
chomp;
if(s@:$@@){$d=$_;next}
if(/\.(txt|html)$/){s@^@$d/@;s/..//;print "<A href=\"$_\">$_</A>\n";
if(/\.html$/){$p->parse_file($_);print "\t",$p->header('Title'),"\n";}}}
print "</PRE></BODY></HTML>";
extra large version) have any stuffing hanging out that perl novice me
ought to fix? Say, how does one do '/bin/sh -e' in perl? Would
rewriting it in python be as easy? Does perl have an internal "ls"
that could be called as easy? File::Find couldn't give me the ls -R
order I prefer I suppose. Goal: to use even less lines of code.
use strict;
require HTML::HeadParser;
my $dir=<~/mywebsite>; #where files are on my computer
my $name="Bob Blobkowski";
my $url='http://blobkowski.org/';
chdir $dir||die;
print <<EOF;
<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd"><HTML><TITLE>$name\'s site map</TITLE>
</HEAD><BODY><H1>$name\'s site map</H1>\n<P><A href="$url">$url</A> as of
EOF
system "date"; print '</P><HR><PRE>';
my $p = HTML::HeadParser->new; my $d;
open LS, "ls -R|"||die;
while(<LS>){ #order nicer than find(1)
chomp;
if(s@:$@@){$d=$_;next}
if(/\.(txt|html)$/){s@^@$d/@;s/..//;print "<A href=\"$_\">$_</A>\n";
if(/\.html$/){$p->parse_file($_);print "\t",$p->header('Title'),"\n";}}}
print "</PRE></BODY></HTML>";