[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cgiapp] broken link from other site, please help


Clint wrote:
On Saturday, December 21, 2002, at 09:24 PM, eric lin wrote:

I tried , it show some compile error in my perl

/usr/bin/perl /usr/lib/cgi-bin/showphoto.pl
Global symbol "$file" requires explicit package name at /usr/lib/cgi-bin/showpho
to.pl line 8.
Execution of /usr/lib/cgi-bin/showphoto.pl aborted due to compilation errors.


    The following works on Mac OS X and Linux

-------
#!/usr/bin/perl -w
use strict;

# Eric, you must first define $filename before you can use it.
#Well, at least when you use strict and that should be always.
my $filename = "/tmp/image.jpg";

print( "Content-type: image/jpg\n\n" );

do {
    # warn puts an error into the logs so that you can read it.
# I dont think printing the error to stdout will show up under a mime type
    # of image/jpg.
    warn( "Cannot open $filename because $!" );
    die( 1 );
} unless open( IN, "<$filename" );

print <IN>;
close( IN );
-------

You should not have much trouble making it work on windows as simple as it is. You should only have to change the #! line and the 'my $filename =' line as far as I know unless the windows port is really wonky.

While I don't mind answering questions no matter what the list, I feel compelled to point out that this list is for CGI::App discussion and that there are many other lists for general Perl CGI programming that are better suited to the task of answering questions like this.

I also respectfully recommend that you pick up a copy of Learning Perl if you are going to do much Perl programming.


PS
I just tested the above code again to make sure before I sent it and I messed up and out of habit (i guess, though nowadays I use CGI) changed the header to 'Content-type: text/html\n\n' and it still worked. It makes sense but was still unexpected.

-cm


---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/suppressed/
To unsubscribe, e-mail: suppressed
For additional commands, e-mail: suppressed



I already copy that piece of code fully,(include cpoy my file.jpg to /tmp/phot.jpg) It is not work in 2.4.20, perl 5.8 if you do not believe you can try http://www.linuxspice.com/cgi-bin/showphoto.pl
on any browser

regard eric /* hope to hear from you again */



--
Sincere Eric
www.linuxspice.com
linux pc for sale


---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/suppressed/
To unsubscribe, e-mail: suppressed
For additional commands, e-mail: suppressed


Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.