Gossamer Forum
Home : Products : DBMan : Customization :

Open file, check......

Quote Reply
Open file, check......
I'm back!!

I'm looking for info on how to look in a file,
see if an image exists,
if it does, print this,
if not, print that.

I tried...

Code:
|;
open ("/home/racedaze/racedaze-www/images/");
if ($rec{'Itemno'}.gif) {
print qq| <img src="http://www.racedaze.com/pageimage/camera.gif">|;
}
else {
print qq| |;
}

Any ideas?
Thanks,
Chris

------------------
webmaster@racedaze.com
Quote Reply
Re: Open file, check...... In reply to
I figured it out..

Code:
|;
if (open (FILE, "/home/racedaze/racedaze-www/images/$rec{'Itemno'}.gif")) {
print qq| <img src="http://www.racedaze.com/pageimage/camera.gif">|;
}
else {
print qq| |;
}

Sloppy?
It works!

Chris

------------------
webmaster@racedaze.com
Quote Reply
Re: Open file, check...... In reply to
You want perl's -e operator:

if (-e "/path/to/image.gif") {
# it exists
}
else {
# nope
}

Cheers,

Alex