package My::Module; sub new{ bless \rand, shift(); } sub do_something{ print 'Do what?'; } return 1; =head1 NAME My::Module - Test my idea. =head1 Synopsys/Example See demo/test code at the end of this module. =head1 Description Demo of idea to integrate a runnable test suite into a module =head1 Copyright Copyright 2003, by BrowserUK. All rights reserved. May be used, copied, altered or sold freely under the same terms and conditions as Perl itself. =head1 Demo/test program. The following code serves as both demo program and test suite. To run the integrated version switch to the directory where the module is located and type: =begin text perl -x Module.pm =end text The program should respond with: =begin text E:\Perl\site\lib\My>perl -x Module.pm Do what? E:\Perl\site\lib\My> =end =cut #! perl use strict; # use My::Module; # Use this instead of the following line in your code. unshift @INC, '.'; require $0; my $test = My::Module->new(); $test->do_something();