TCLUG Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [TCLUG:1872] Is this hard to do?



> syntax error at /home/httpd/cgi-bin/script.pl line 14, near "printf"
> Execution of /home/httpd/cgi-bin/script.pl aborted due to compilation
> errors.
> 
> Line 14 is  printf "Content-type: image/gif\n\n";

Hmm.. I would try checking the line _before_ the error

Read below:

> > ---- Cut After this line.  --
> > #!/usr/bin/perl
> >
> > #all images in the image directory.
> > $imagedir="/usr/local/www/data/banners";
> > $defaultimage="/usr/local/www/data/linux.gif";
> >
> > sub show_image # filename
> > {
> >       my($file) = @_;
> >
> >      #send the mime type, can make it intelligent to see what kind of image
> > file it is
> >      #and then set the appropriate mime type.
> >       printf "Content-type: image/gif\n\n";

You don't by chance still have 'file it is' on the 12th line, do you?
That text is supposed to be quoted..

> >       #Read the input file and print it to output.
> >       open( INP, "< $file" );
> >       while( read( INP, $buf, 1024 ) ) {
> >               print $buf;
> >       }
> >       close( INP );
> > }
> >
> > #Open the imagedir and read the list of files in there.
> > if ( !opendir( DIR, $imagedir ) )
> > {
> >       &show_image( $defaultimage );
> > }
> > else
> > {
> >       #Read the image files and pick up a random one, This will only get the files
> >       # in the imagedir.
> >       @filelist = grep { -f "$imagedir/$_" } readdir( DIR );
> >       closedir( DIR );
> >       if( $#filelist < 0 )
> >       {
> >               #didnot find any.
> >               &show_image( $defaultimage );
> >       }
> >       else
> >       {
> >               $loc = rand;            #this will call srand.
> >               $loc *= $#filelist;     #Use it to index into the list.
> >               $loc = int($loc);
> >               &show_image( "$imagedir/$filelist[$loc]" );
> >       }
> > }
> >
> > __END__
> >
> > -- This is the end of the script. --
-- 
                    --== Mike Hicks ==--
http://umn.edu/~hick0088	mailto:hick0088@tc.umn.edu
                        ICQ:6883760
Linux User Since 1.2.13            Current Kernel: 2.1.125