Petras has asked for the wisdom of the Perl Monks concerning the following question:
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
-Howard Aiken
Edit by castaway - move readmore tags outside of code tags
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: CGI throws in an extra character. Why?
by Your Mother (Archbishop) on Dec 01, 2004 at 05:43 UTC | |
by Petras (Friar) on Dec 01, 2004 at 20:07 UTC | |
by Your Mother (Archbishop) on Dec 02, 2004 at 03:52 UTC | |
Re: CGI throws in an extra character. Why?
by davido (Cardinal) on Dec 01, 2004 at 05:43 UTC | |
by Anonymous Monk on Dec 01, 2004 at 07:01 UTC | |
by davido (Cardinal) on Dec 01, 2004 at 07:05 UTC | |
by Petras (Friar) on Dec 01, 2004 at 05:50 UTC | |
by ikegami (Patriarch) on Dec 01, 2004 at 06:25 UTC | |
Re: CGI throws in an extra character. Why?
by Anonymous Monk on Dec 02, 2004 at 13:12 UTC |