bryce at bryceharrington.com
Tue Jun 22 22:34:52 PDT 2004
On Tue, 22 Jun 2004, Jonadab the Unsightly One wrote:
> One thing that would add convenience would be if I could have
> it parse straight from a scalar (taken from form input), rather
> than from a file. If there's a way to do this, I don't see it
> documented in the POD. I'd like to take the SVG from an XHTML
> file input, metadata from other form inputs, use SVG::Metadata to
> add those metadata to the SVG en situ, do some minimal validation
> (e.g., make sure the mandatory metadata fields are all specified)
> and then only write the finished product to an actual file. I
> can work around this with a temporary file, though, if necessary.
Okay, I've augmented parse() a bit. I found that XML::Twig provides
several functions for different kinds of parsing, so have added the
* If the string passed in has two or more newlines, it's assumed to
be a text string and parsed as that.
* If it's an open IO::Handle, it's parsed thataway
* If begins with 'http' or 'ftp', it's assumed to be a URL, and
downloaded and parsed.
* Otherwise, it's assumed to be a filename and loaded from the file
I wonder whether it is better to have it a single parse() function that
figures out what to do, or to break it into four separate parsing
functions and require the caller to know what type of input they want.
Got a preference?
More information about the clipart