#! /usr/bin/perl -w # vim:set ts=2 sw=2 expandtab: # doc-cmd - filter to process embedded shell commands in XML document # Suppose a document contains this: # # # ... a bunch of stuff here # # Then you mark the lines in the file from the comment to the closing # tag and shove it through doc-cmd. In vi, with the cursor # on the comment line, you could do this with 4!!./doc-cmd. doc-cmd # reads the first line, extracts the command, runs it, and writes as # its output the original comment line plus the output from the command. # This provides a way to embed within an XML document a command that # produces part of a document, plus an easy way to re-run the command # should the document fragment need to be regenerated. use strict; $_ = <>; die "Did not find an XML comment containing a command\n" unless /\