#!/usr/bin/perl -w use strict; # save & localize $, as necessary my @pics = qw( pic0 pic1 pic2 pic3 pic4 pic5 pic6 pic7); my $pic_preface = " pre "; my $pic_suffix = " suf "; my $next_row = " end_row\n"; my $table_end = "\ntable end\n"; my $pics_per_row = 5; { my $i; for ( $i=1; $i <= @pics; $i++) { print "$pic_preface", $pics[$i-1]; print ( 0 == $i % $pics_per_row ? $next_row : $pic_suffix); } print $next_row unless 0 == $i % $pics_per_row; print $table_end; }