On Github alexm / writing-tutorials-for-perltuts
by Alex Muntada / @alexmuntada
Viacheslav Tykhanovskyi (vti) started Perltuts on 2012
=head1 NAME Title of the tutorial =head1 ABSTRACT Short description in the list of tutorials. =head1 DESCRIPTION Long description in the beginning of the tutorial. =head1 TUTORIAL Tutorial content.
(basic example)
=head1 NAME Quick start =head1 ABSTRACT This tutorial is a quick start for non-experienced non-programmers. It tries to cover the basics and does so in a gradual manner. =head1 DESCRIPTION This tutorial is a quick start for non-experienced non-programmers. It tries to cover the basics and does so in a gradual manner.
=head1 TUTORIAL =head2 Hello, world! Let's try from the simple example. This example is a common example in all programming tutorials and books, it prints "Hello, world!". Try running the following program, you should see the output. say 'Hello, world!' Here C<say> is a function that accepts arguments and prints them out. =head3 Exercise Try fixing the following code so it prints 'Bye': say '' __TEST__ like($stdout, qr/Bye/, 'Should print Bye');
(advanced example)
=head1 NAME PDL =head1 ABSTRACT An introduction to the PDL extension to Perl. =head1 DESCRIPTION This tutorial is an introduction to the Perl Data Language (PDL) which is an array-oriented mathematical module for Perl. The official PDL website is L<http://pdl.perl.org>.
=head1 INCLUDES /js/jquery.flot.min.js =head1 JAVASCRIPT $('.test').after('<div class="plot hidden"></div>'); $.plot($('.plot'), []); =head1 HANDLER (function(data) { var plot=$(form).children('.plot').first(); $(plot).removeClass('hidden'); if (data.result.constructor == Object && data.result.plot) { $.plot($(plot), data.result.plot); } else { $(plot).addClass('hidden'); $.plot($(plot), []); } })(data);
=head1 MODULES PDL =head1 PREAMBLE use PDL::LiteF; use Scalar::Util 'looks_like_number'; sub plot { my @datasets = @_; my @output_datasets; for my $dataset (@datasets) { # ... } return +{plot => \@output_datasets}; }
=head1 TUTORIAL =head2 Simple Plotting This tutorial uses a custom javascript plotting system built on the Flot library (L<http://code.google.com/p/flot/>). The plotting interface provided by C<perltuts.com> is still under heavy development and may change. The C<plot> command accepts a list of datasets to be plotted. Valid datasets include a simple arrayref of y values (x values will be generated), plot([1, 2, 3]);
Title of the tutorial.
Short description in the list of tutorials.
Long description at the beginning of the tutorial.
External script element to load javascript code.
Embedded javascript code.
Javascript code to handle the data produced in Perl (e.g. plot).
Perl distributions needed to run the code.
Perl code to run before tutorial code.
The contents of the tutorial.
Chapter titles listed in the table of contents.
Questions?
(all logos are from Wikipedia, cc-by-sa)