#!/usr/bin/perl $/ = ""; while (<>) { $_ =~ s/(\n) +/$1/g; s/ +/ /g; if ($_ !~ /^\%/) { s/(.*)\n/$1 /g; } s/ +/ /g; s/(\%year\:.*?\n)/\%Start\:\n\%sortkey\:\n\%headword\:\n\%pos\:\n\%page\:\n\%col\:\n\%chap\:\n$1/; s/(\%year\:.*?\n)/$1\%author\:\n\%story\:\n\%mag\/book\:\n\%date\:\n\%place\:\n\%ed:\n\%anthology\:\n\%section\:\n/; s/(\%www.*\n)/$1\%def\:\n\%notes\:/; s|(\%www:)http://|$1|; print; } print "\n\%End\:\n"; #%Start: #%sortkey: #%headword: #%pos: #%page: #%col: #%chap: #%year: #%author: #%story: #%mag/book: #%date: #%place: #%ed: #%anthology: #%section: #%cit: #%www: #%def: #%notes: #%End: