#!/opt/local/gnu/bin/perl -w # A little script that converts my netscape bookmarks to a single page push(@ARGV,"/homes/gregg/.netscape/bookmarks.html"); $out = "bookmarks.html"; open(BM,">$out"); #sub heading { # if ((/<(TITLE)>/) || (/<(H1)>/) || (/^
]*> *([^<]*)/)) { # $head = $1; # next LOOP; # } # elsif (/^
]*>([^<]*)/) { # $subhead = $1; # next LOOP; # } # } sub chkline { if ($line) { $line =~ s/^(.*)\|/$1]/; print BM "$line"; $line = ""; } } print BM '',"\n"; print BM "\n"; LOOP: while (<>) { if (/<(TITLE)>/) { $head = $1; print BM $_; print BM "\n"; print BM '',"\n"; next LOOP; } if (!$head) { next LOOP; } if (/<(H1)>/) { $head = $1; print BM $_; next LOOP; } if (/^[ ]*$/) { next LOOP; } if (/^

/) { next LOOP; } if (/^

]*> *([^<]*)/) { $head = $1; $subhead = ""; if ($head ne "Frequent Access") { print BM "$head\n"; } next LOOP; } if (/^

/) { $line = ""; next LOOP; } if (s/^[ ]*

(]*/$1/) { if ($line) { print BM "$line"; ($line = $_) =~ s/^(.*)/ $1|/; } else { ($line = $_) =~ s/^(.*)/[$1|/; } $line =~ s?file:/u/gregg/.netscape/??; next LOOP; } if (/^ *<\/DL>

/) { &chkline; if ($head eq "Frequent Access") { print BM "


\n"; } elsif (((/^ \n"; } elsif (!$subhead) { print BM "

\n"; } next LOOP; } if (/^ *

/) { $line = ""; next LOOP; } if (/^

]*>([^<]*)/) { if (!$subhead) { &chkline; print BM "
    \n"; } $subhead = $1; $subsubhead = ""; print BM "
  • $subhead\n"; next LOOP; } if (/^
    ]*>([^<]*)/) { if (!$subsubhead) {print BM "
      \n";} $subsubhead = $1; print BM "
    • $subsubhead\n"; next LOOP; } } print BM "\n"; system("chmod a+r $out");