Gossamer Forum
Home : General : Perl Programming :

Simple Problem...

Quote Reply
Simple Problem...
Hello, people.
Sorry for my English. I am foreigner.

I have a small problem with gif/jpeg files showing.

---perl code-----
#!/usr/bin/perl
#gif.pl
print "Content-Type: image/gif\n\n";
open(FILE,"22.gif");
print <FILE>;
close(FILE);
-------end--------

I use <!--#include virtual="/cgi-bin/gif.pl" -->
in html page.
But this not work.

Please, explain.

Thank you!
---
best regards
sensor
Quote Reply
Re: [Sensor] Simple Problem... In reply to
Start by telling us what happens ;) ...before you do that though, add some error checking.

open( ... ) or die $!;

Last edited by:

Paul: May 24, 2003, 9:05 AM
Quote Reply
Re: [Paul] Simple Problem... In reply to
This code is a part of script "Pictures of the day".

open(PIC,"4/01") or die...(etc); open w/o errors

If there is file.txt instead the picture, it will work properly. But i need to open pic. ;)
---
best regards
sensor
Quote Reply
Re: [Sensor] Simple Problem... In reply to
Try this;

Code:
#!/usr/bin/perl
#gif.pl
use CGI::Carp qw(fatalsToBrowser);
print "Content-Type: image/gif\n\n";

open(FILE,"22.gif") || die "Cant open. Reason: $!";
print <FILE>;
close(FILE);

I have a feeling it has something to do with the slashes in your variable. Remember, its a file name, but Perl will treat forward slashes as 'folders'.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Simple Problem... In reply to
Above your print you'll want:

binmode FILE;
Quote Reply
Re: [Paul] Simple Problem... In reply to
Whoops...my boo boo. I should have known that, especially after just playing with Image::Magick Blush

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Paul] Simple Problem... In reply to
Only if it's being run on a Windows box.

Binmode won't do anything on your linux box.

- wil