if (@ARGV > 1) { print STDERR "Usage: perl convert-sheets.pl [foo.sheets] > new.sheets\n"; exit(1); } print <) { if (!/^type=([a-z]*), id=([%A-Za-z0-9:]*)$/) { die "Couldn't parse object header: $_\n"; } $type = $1; $id = $2; print "object $id\n"; if ($type eq "sheet") { $_ = <> || die "EOF in the middle of sheet $id?\n"; (($title) = /^ (.*)$/) || die "Bogus title for sheet $id: $_\n"; $_ = <> || die "EOF in the middle of sheet $id?\n"; (($filename) = /^ (.*)$/) || die "Bogus filename for sheet $id: $_\n"; print " filename=$filename\n" unless $filename eq ""; print " title=$title\n"; print " type=$type\n"; print "section components $id\n"; } else { print " type=$type\n"; print "section text $id\n"; } while (($_ = <>) && ($_ ne "-----------------\n")) { s/^ / / || die "Bogus line in $type component $id: $_\n"; s/\\/\\\\/g; print; } }