Gossamer Forum
Home : Products : DBMan : Customization :

Cant get Perls "-e operator" to work.

Quote Reply
Cant get Perls "-e operator" to work.
I got this code from the FAQ board:

Code:
|;

if (-e "$SAVE_DIRECTORY_URL/$rec{$db_key}/$photo[1]") {
print qq|<img src="$SAVE_DIRECTORY_URL/$rec{$db_key}/$photo[1]">|;
}
else {
print qq|<img src="http://www.wdu.net/images/sfimages/blank.gif">|;
}
print qq|

but it doesn't work. Always shows my alternate (blank.gif) image even if there is a file there.
This works:
Code:
<img src="$SAVE_DIRECTORY_URL/$rec{$db_key}/$photo[1]">

So I know it has something to do with the other peice of code. I need the e operator in there so it doesnt show little red x's when the user doesnt upload all the files. I cant figure out whats wrong with it.
Quote Reply
Re: [wdu2002] Cant get Perls "-e operator" to work. In reply to
If it always shows the default that means the image url is wrong.

$SAVE_DIRECTORY_URL/$rec{$db_key}/$photo[1]

Try printing out out to see what it says.
Quote Reply
Re: [RedRum] Cant get Perls "-e operator" to work. In reply to
But the image url cant be wrong if it prints out fine when I try

<img src="$SAVE_DIRECTORY_URL/$rec{$db_key}/$photo[1]">

If I just type in that like I would to view the image, it prints on the record fine, but when I try to add the statement in there to check to see if the image is there first, it says its not, but it really is. It wouldnt print it the other way if it wasnt. Im confused. This is giving me a headache Unsure

Quote Reply
Re: [wdu2002] Cant get Perls "-e operator" to work. In reply to
Use $SAVE_DIRECTORY instead of $SAVE_DIRECTORY_URL.

The latter is a html link, the former has the full server path to your directory.

Perl expects full server paths for the -e switch to work.
kellner