Hi, everybody!

This is a chunk of code that is supposed to make a table of thumbnails. The form elements have a purpose--ultimately I want to be able to view a directory of images and rename them through a CGI script (untill I have a time to read Mastering Perl/TK, that is). But that's not the point.

The BIG QUESTION is, why, using Indigo Perl 5.8 and IE 6.029, why does a number one ("1") render at the bottom of the page? Where does that come from?

There is a lot of non-conforming code here. Feel free to blast my newbie-style in response, but that's not really what this post is about ;)

#! perl -wT use CGI; use CGI::Pretty; use strict; use File::Basename; #so I can use dirname(); use DirHandle; #so I can use opendir(); use strict; # eventual the path will come from an env variable from a calling webp +age my $path=dirname('c:/pictemp/start.gif'); my @files; opendir(DIR, $path); @files = readdir(DIR); # This ugly section drops the '.' and '..' from the directory array. # It looks juvenile, but it works. my $junk; if ($files[0] eq '.' ) { $junk = shift @files; } if ($files[0] eq '..' ) { $junk = shift @files; } my $query = CGI->new(); print $query->header( "text/html" ), $query->start_html(-title => "Renaming Digital Photos", -bgcolor => "#ffffcc" ); print "<form name=newNameForm method=post action=rename.cgi>\n"; print $query-> input( { -name=> "baseDir", -type=> "hidden", -value=> "$path"} ); print "\n<table border=1><tr valign=top>\n"; my $file; my $counter=0; my $tempFile; foreach $file (@files) { $tempFile=$path."/".$file; print "<td>\n\t".$file."<br>\n\t"; print $query->input ( { -type=>'hidden', -name=>"'hidden'.$counter", -value=>"$file" } ); print "\n\t"; print $query->input ( { -type=>'text', -name=>"'newName'.$counter", -size=>"30", -value=>$file } ); print "\n\t<img width=200 src=".$tempFile.">\n\t</td>\n"; if ( ++$counter % 3 == 0) { print "</tr><tr valign=top>\n"; } } print "</tr></table>"; print #query->end_html; closedir(DIR);

It displays a table, with appropriate file names, form fields, and thumbnails, but after the table an extra "1" shows up. What's going on?

Pease out,

Petras

Don't worry about people stealing your ideas. If your ideas are any good, you'll have to ram them down people's throats.

-Howard Aiken

Edit by castaway - move readmore tags outside of code tags


In reply to CGI throws in an extra character. Why? by Petras

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.