#!perl use common::sense; use Moose::Autobox; my $slide_header = q Message Based Programming ; system 'rm -f sl_*'; my $get_slide_filename = sub { my $n = shift; my $filename = sprintf('sl_%05d.html', $n); return $filename; }; my $write_slide; { my $slide_ct = 0; $write_slide = sub { my $slide = shift; $slide_ct++; my $filename = $get_slide_filename->($slide_ct); open my $fh, '>', $filename; my $s = $slide_header; my $forward_slide = $get_slide_filename->($slide_ct + 1); my $backward_slide = $get_slide_filename->($slide_ct - 1); $s =~ s/FORWARD_SLIDE/$forward_slide/m; $s =~ s/BACKWARD_SLIDE/$backward_slide/m; say $fh $s; say $fh $slide; say $fh ''; close $fh; }; } my $slide = ''; my $code_slide = 0; my $fh = open my $fh, '<', 'slides.txt'; while(my $line = <$fh>) { chomp $line; if($line =~ /^#/) { $code_slide = 1; $line =~ s/^#//; } if($line =~ /^$/) { if($code_slide) { $write_slide->("
$slide
"); } else { $write_slide->("

$slide

"); } $slide = ''; $code_slide = 0; } $slide .= "$line\n"; } __END__ my @a = []; my $ct = 0; while(1) { push @a, 'xyzzy' x 1024; $ct++; for($ct) { my $thing = $a[$ct]; } }