Schedule Generator

1.0 Perl Artistic License    
3.4/5 14
Schedule Generator is a little Perl script that draws up a weekly schedule as a Scalable Vector Graphics image.




Schedule Generator is a little Perl script that draws up a weekly schedule as a Scalable Vector Graphics image. Running it on your own computer may take some basic knowledge of how to use a command line, but the form interface on the demo site ought to be usable by anybody.

It's implemented as a module rather than a standalone program so that the same code can be used in a CGI script (as on the demo site) or a Perl one-liner. It depends on the SVG module.

You can call the One True Class Method of Schedule Generator, "as_string", from any Perl program. (See the POD embedded in for the details.) But if you just want to draw a schedule, the best way, I think, is to write your data structure in YAML, then run this command:

cat example.yml | perl -e 'use Local::Schedule_Generator; use YAML; print Local::Schedule_Generator->as_string(%{Load do {local $/; < STDIN >;}});' > /tmp/sched.svg; inkview /tmp/sched.svg

where "example.yml" is the name of the file, and "inkview" is the name of an SVG-compatible image viewer of your choice, Inkview itself being a good candidate. Try this on the "example.yml" distributed with this program. (Make sure your current working directory is the one containing the "Local" directory and this README.) If you've never heard of "YAML" before, have no fear; it's the most intuitive data serialization language imaginable. It looks uncannily like plain text. Just edit "example.yml" to your liking. For a five-minute crash course on YAML, should you be interested, see "". For more information, see "" and the documentation for Perl's YAML module.

If you want a bitmap version of Schedule Generator's output, you can open the image with Inkscape and use its export feature, or you can use ImageMagick to turn the SVG (fed through standard input) into a PNG (emitted via standard output):

convert svg:- png:-

This is, in fact, the command my CGI script uses to create its PNG output.

You may wonder why I put in the "Local" namespace. My thinking went like this: Schedule Generator doesn't belong on CPAN, since it's much too specific to be considered reusable code. Then it would be misleading to put it somewhere in the standard CPAN hierarchy, even though the underscore would protect it from namespace collisions. So I put it under "Local" to underscore (hee hee) its nonstandard-ness.

One final note: if you want finer control over Schedule Generator's output, look in under "Hard-coded options". All the numeric variables that control the exact proportions of the schedule are there for your editing pleasure. Please excuse my brace style. I have poor eyesight, so I use such a large font for programming that I can only fit about twenty lines in one Emacs frame. For that reason, I tend to write visually compact code. It actually looks a little Pythonic, even though I'm a Perl fanboy. But TIMTOWTDI, right?
Last updated on May 14th, 2008
Schedule GeneratorSchedule Generator

0 User reviews so far.