The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Pod::ToDemo - writes a demo program from a tutorial POD

SYNOPSIS

        use Pod::ToDemo <<'END_HERE';

        print "Hi, here is my demo program!\n";
        END_HERE

DESCRIPTION

Pod::ToDemo allows you to write POD-only modules that serve as tutorials which can write out demo programs if they're invoked directly. That is, while SDL::Tutorial is a tutorial on writing beginner SDL applications with Perl, you can invoke it as:

        $ perl -MSDL::Tutorial=sdl_demo.pl -e 1

and it will write a bare-bones demo program called sdl_demo.pl based on the tutorial.

USAGE

Call Pod::ToDemo::write_demo() with two arguments. $filename is the name of the file to write. If there's no name, this function will die() with an error message. If a file already exists with this name, this function will also die() with another error message. The second argument, $demo, is the text of the demo program to write.

If you're using this in tutorial modules, as you should be, you will probably want to protect programs that inadvertently use the tutorial from attempting to write demo files. Pod::ToDemo does this automatically for you by checking that you haven't invoked the tutorial module from the command line.

To prevent perl from interpreting the name of the file to write as the name of a file to invoke (a file which does not yet exist), you must pass the name of the file on the command line as an argument to the tutorial module's import() method. If this doesn't make sense to you, just remember to tell people to write:

        $ perl -MTutorial::Module=I<file_to_write.pl> -e 1

AUTHOR

chromatic, <chromatic at wgz dot org>

BUGS

No known bugs, now. Thanks to Greg Lapore for helping me track down a bug in 0.10 and to rrwo for Windows test tweaks.

COPYRIGHT

Copyright (c) 2003 - 2004, chromatic. All rights reserved. This module is distributed under the same terms as Perl itself, in the hope that it is useful but certainly under no guarantee.