Thanks Monks!!! @row_entries= splice (@piclist, 0, 5); was a new concept for me. It doesn't appear in Learning Perl and is only given a cursory glance in Programming Perl. The final code for this is below. Just set the root of your images directory. Simple and quick. I tried to keep the code readable (and because I'm still a Perl novice). This displays 5 images per row, then it starts again (thanks Randal!) Just before the image src HTML, I'm stripping off the full path and assuming the image path is /images/$_
$startdir="/www/intranet/images"; push(@dirs,$startdir); foreach $dir (@dirs) { opendir(DIR,"$dir") || die "opendir $dir failed"; @list = grep(!/^\.\.?$/,readdir(DIR)); closedir(DIR); foreach $item (@list) { $fullname = $dir."/".$item; # add the directory name to th +e file name if (-d $fullname) { push(@dirs,$fullname); print "$item<br>"; } } } print "Content-type:text/html\n\n"; &parse; print qq| <html> <head> <link rel="stylesheet" type="text/css" href="/include/style.css"/> </head> <body> <p> <form action=/cgi-bin/images.cgi method=post> <select name=pic> <option value=$FORM{'pic'} selected>$FORM{'pic'} |; foreach $thisdir (@dirs) { print qq| <option value="$thisdir">$thisdir |; } print qq| <input type=submit value="Go!"> </form> </html> |; opendir(DIR,"$FORM{'pic'}") || die "opendir $dir failed"; @piclist = grep(!/^\.\.?$/,readdir(DIR)); closedir(DIR); print "<table cellpadding=10 cellspacing=0 width=100%>"; while (@piclist) { my @row_entries= splice (@piclist, 0, 5); print "<tr>"; for (@row_entries) { print "<td>"; $FORM{'pic'} =~ s/\/www\/intranet//; print qq| <img src=$FORM{'pic'}/$_><br>$_<p> |; print "</td>"; } print "</tr>"; } sub parse { read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); @pairs = split(/&/, $buffer); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $FORM{$name} = $value; } }

In reply to simple image gallery generated by server image directory by monkscafe
in thread simple column/row counter by monkscafe

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.