#!/usr/local/bin/perl
# gophertree v1.0
# Prints pretty indented listings of a Gopher menu tree
# Copyright (C) 1992, Trustees of Michigan State University
#
# Modifications:
# Original author unknown
# 07/07/92 Boone Major conversion from gopherls
# 08/14/92 Boone Fixes:
# added code to allow command line limit on recursion
# depth
# quit indenting after 15 levels to avoid filling the
# title field with spaces
# changed to use IP address instead of hostname when
# checking for off-host links; this should make
# aliased machine names (e.g. gopher.someschool.edu)
# work much better
# Enhancements:
# Added option to list only directories
# Changed limit on number of items listed to apply to
# all types except directories, instead of just
# files; still no per-type limits though
# Changed command line processing to use Getopts,
# allowing better option processing
# End Modifications
$^ = 'TOP'; # Report header format
$~ = 'STDOUT'; # Report body format
$indent = ""; # Goes in front of description to indicate treeness
$depth = 1; # How deep into the maze are we?
$hostable{$firsthost} = unpack("L", (gethostbyname($firsthost))[4]);
# CHANGE--User-configurable defaults
$breaklong = 15; # CHANGE--Where to break long lists
$= = 55; # CHANGE--Lines per page
$iadd = " "; # CHANGE--Amount to indent each new level
$nomoreindent = 15; # CHANGE--How far down before we quit indenting
$maxdepth = 999; # CHANGE--How deep to go before "pruning" layers
# Stuff command line changes into the config variables
if ($opt_b) { $breaklong = $opt_b; }
if ($opt_l) { $= = $opt_l; }
if ($opt_r) { $maxdepth = $opt_r; }