#!/usr/local/bin/perl -w # # Pull the headers out of the incoming document. $type = "" ; $what = "" ; $content = "" ; while (<>) { last if /^\)HEAD$/ ; # Exit at end of head element # Gather information $what = 'type' if /^\(TYPE$/ ; $what = 'content' if /^\(CONTENT$/ ; $type = &deasp($_) if $what eq 'type' && s/^-// ; $content = &deasp($_) if $what eq 'content' && s/^-// ; # Should have one, set up to print if (/^\)(ALT)?HDR$/) { chop($type) ; if (/^\)ALT/) { $altheaders{$type} = $content ; } else { $headers{$type} = $content ; } } } foreach $key (keys(%headers)) { print "$key:$headers{$key}" ; } print "\n" ; # Blank line to terminate headers foreach $key (keys(%altheaders)) { print "$key:$altheaders{$key}" ; } print "\n" ; # Blank line to terminate alternate headers sub deasp { local($_) = pop(@_) ; s/\\\\/\\/g ; s/\\([0-8]{3})/pack(C,oct($1))/ge ; s/\\n/\n/g ; return $_ ; }