#!/usr/local/bin/perl # gendc # # andy powell # # $Id: gendc,v 1.5 1997/03/20 12:35:58 lisap Exp $ # # Generate Dublin Core META tags suitable for embedding in an HTML document. use Getopt::Std; $rcfile = "$ENV{'HOME'}/.gendcrc"; sub newrc { open(RC, ">$rcfile") || die "Can't create $rcfile"; print RC <) { chop; if (/^#/) { push(@prompt, $_); next; } my ($element, $scheme, $link, $defval) = split(/;/); my $sub .= "(SCHEME=$scheme)" if ($scheme); my $key = "$element $sub"; push(@prompt, $key); $Element{$key} = $element; $Scheme{$key} = $scheme; $Link{$key} = $link; $Defval{$key} = $defval; $Sub{$key} = $sub; } close(RC); } } sub saverc { open(RC, ">$rcfile") || die "Can't save settings"; foreach (@prompt) { if (/^#/) { print RC "$_\n";; next; } print RC "$Element{$_};$Scheme{$_};$Link{$_};$Defval{$_}\n"; } close(RC); } sub ask { local($q, $a) = @_; print STDERR "$q"; print STDERR " [$a]" if ($a); print STDERR " : "; chop($newa = ); if ($newa eq ' ') { return(''); } $newa =~ s/^\s*//; $newa =~ s/\s*$//; $newa =~ s/;/:/g; # Sigh, simple hack - ';' is the separator in the RC file $a = $newa if ($newa); return($a); } getopts('f'); &newrc unless (-f $rcfile); &loadrc; print STDERR <\n" if ($opt_f); foreach (@prompt) { next if (/^#/); $key = $_; next unless ($Defval{$key}); print STDOUT "\n"; print STDOUT "\n" if ($opt_f); print STDOUT "\n" if ($Link{$key} && $opt_f); } # print STDOUT "\n" if ($opt_f); # Print Alta-Vista metadata print STDOUT "\n" if ($Defval{'description '}); print STDOUT "\n" if ($Defval{'subject '});