#!/usr/bin/perl
use warnings;
use strict;
my @images;
for (1 .. 20) { push @images, "image$_.gif";}
my $x_wide = 6; # user supplied value
my $output = "
\n";
my $i = 0;
while ($i < scalar @images) {
$output .= "\n";
for (my $j=0; $j<$x_wide; $j++) {
if ($images[$i]) {
$output .= "\t | \n";
$i++;
}
}
$output .= "
\n";
}
$output .= "
";
print $output;