Loading ...
Sorry, an error occurred while loading the content.

-e problem

Expand Messages
  • Lou Hernsen
    I use the -e to check to see if a file is present if (-e $Pics/$Game{Page}.jpg ) { } Question I can get it to work looking for .pl and .gif but not .jpg I
    Message 1 of 5 , Dec 15, 2006
    • 0 Attachment
      I use the -e to check to see if a file is present

      if (-e "$Pics/$Game{Page}.jpg")
      {
      }

      Question
      I can get it to work looking for .pl and .gif but not .jpg

      I have checked all the directorie vars and even did this

      print qq|<img border=0 src="$Pics/Camera.gif" width="$Game{CameraW}"
      height="$Game{CameraH}"><BR>|;
      print qq|<BR>|;
      print qq|<a target="$Game{Page}" href="$Pics/$Game{Page}.jpg">|;
      print qq|<img border=0 src="$Pics/Camera.gif" width="$Game{CameraW}"
      height="$Game{CameraH}"><BR>|;
      print qq|</a>|;
      print qq|<BR>|;
      if (-e "$Pics/$Game{Page}.jpg")
      {
      print qq|<img border=0 src="$Pics/Camera.gif" width="$Game{CameraW}"
      height="$Game{CameraH}"><BR>|;
      }

      I get the first two images but not the last one.. so I know i have the dirs
      correct
      are .jpg's not -e able???

      yeah.. i'm nonprofessional hobbiest .... my style suck... can someone answer
      the question, please?
      Lou
    • Rob Biedenharn
      ... Without knowing your platform or seeing the $Pics directory contents, I d venture a guess that your file system is case-sensitive and the extension is
      Message 2 of 5 , Dec 15, 2006
      • 0 Attachment
        On Dec 15, 2006, at 10:41 AM, Lou Hernsen wrote:

        > I use the -e to check to see if a file is present
        >
        > if (-e "$Pics/$Game{Page}.jpg")
        > {
        > }
        >
        > Question
        > I can get it to work looking for .pl and .gif but not .jpg
        >
        > I have checked all the directorie vars and even did this
        >
        > print qq|<img border=0 src="$Pics/Camera.gif" width="$Game{CameraW}"
        > height="$Game{CameraH}"><BR>|;
        > print qq|<BR>|;
        > print qq|<a target="$Game{Page}" href="$Pics/$Game{Page}.jpg">|;
        > print qq|<img border=0 src="$Pics/Camera.gif" width="$Game{CameraW}"
        > height="$Game{CameraH}"><BR>|;
        > print qq|</a>|;
        > print qq|<BR>|;
        > if (-e "$Pics/$Game{Page}.jpg")
        > {
        > print qq|<img border=0 src="$Pics/Camera.gif" width="$Game
        > {CameraW}"
        > height="$Game{CameraH}"><BR>|;
        > }
        >
        > I get the first two images but not the last one.. so I know i have
        > the dirs
        > correct
        > are .jpg's not -e able???
        >
        > yeah.. i'm nonprofessional hobbiest .... my style suck... can
        > someone answer
        > the question, please?
        > Lou

        Without knowing your platform or seeing the $Pics directory contents,
        I'd venture a guess that your file system is case-sensitive and the
        extension is ".JPG" (or possibly ".jpeg" or anything else that
        doesn't match).

        Care to give us a bit more to go on? There's no reason that -e would
        exclude files based on their extension.

        -Rob

        Rob Biedenharn http://agileconsultingllc.com
        Rob@...
      • Mike Southern
        ... OR ... It seems like the code is checking for the existence of a file, in order to then build an IMG link to that file. It looks like the links and the
        Message 3 of 5 , Dec 15, 2006
        • 0 Attachment
          On 12/15/06 11:22 AM, Rob Biedenharn at Rob@... wrote:

          >
          > Without knowing your platform or seeing the $Pics directory contents,
          > I'd venture a guess that your file system is case-sensitive and the
          > extension is ".JPG" (or possibly ".jpeg" or anything else that
          > doesn't match).
          >
          > Care to give us a bit more to go on? There's no reason that -e would
          > exclude files based on their extension.

          OR ...

          It seems like the code is checking for the existence of a file, in order to
          then build an IMG link to that file.

          It looks like the links and the code is working and as you say it shouldn't
          exclude .jpg

          But if the end result is a browser page and that jpeg does not conform to a
          proper spec (for example if it is a CMYK jpeg) then the browser just won't
          display it.

          That *looks* like a code -e problem, but actually it's a jpeg file format
          problem.
        • Lou Hernsen
          ok here is my test code I put a X and a Z next to teh two images in question so i can see which part of the code is running. i should get two images of the
          Message 4 of 5 , Dec 15, 2006
          • 0 Attachment
            ok here is my test code
            I put a "X" and a "Z" next to teh two images in question so i can see which
            part of the code is running.
            i should get two images of the camera.gif and the page.gif button.
            i only get one camera and the "X" showing me that the -e code is not seeing
            the .jpg

            what it is supposed to do is saythat...
            if there is a picture of the product (the jpg) show the camera.gif
            if there is no product picture, do not show the camera.gif

            the only thing i can think of at this point is that the path may be
            different for the HTML code than the CGI code...
            and I feeel i'm about to just sit here and try that.
            that in the HTML the dir/dir/picture.jpg works
            but in the CGI the path may have to be .../dir/dir/pictures.jpg
            to back out of the cgi dirs and into tthe html dir???

            main dir
            cgi dir
            project dir (where my cgi is)
            html dir
            image.dir (where the picture is)

            maybe????????
            well here is the code... its not professional.. so don't barf

            foreach my $Page(@Pages)
            {
            $Game{Page} = $Page;
            $Game{Page} =~ tr/ -/__/;

            # if the pakage is present
            if (-e "$Game{Page}.pl")
            {
            if ($Order{Verified} ne "")
            {
            # camera pic
            print qq|<table style="margin-bottom: -.5em"><tr><td>|;

            print qq|<a target="$Game{Page}" href="$Pics/$Game{Page}.jpg">|;
            print qq|X<img border=0 src="$Pics/Camera.gif" width="$Game{CameraW}"
            height="$Game{CameraH}"><BR>|;
            print qq|</a>|;

            if (-e "$Pics/$Game{Page}.jpg")
            {
            print qq|<a target="$Game{Page}" href="$Pics/$Game{Page}.jpg">|;
            print qq|Z<img border=0 src="$Pics/Camera.gif" width="$Game{CameraW}"
            height="$Game{CameraH}"><BR>|;
            print qq|</a>|;
            }
            print qq|</td><td>|;

            $Game{TButtonW}=$Game{ButtonW};
            $Game{TButtonH}=$Game{ButtonH};
            print qq|<form action="/cgi-bin/$MainDir/$GameName" method="post">|;
            print qq|<input type="hidden" name="page" value="$Page">\n|;
            print qq|<input type="hidden" name="Verified"
            Value="$Order{Verified}">\n|;
            print qq|<input type="hidden" name="Phone" value="$Input{Phone}">\n|;
            print qq|<input type="hidden" name="PW" value="$Input{PW}">\n|;
            print qq|<input type="image" src="$Pics/$Game{Page}.gif"
            width="$Game{TButtonW}" height="$Game{TButtonH}">\n|;
            print qq|</form>\n|;
            }
            else
            {
            print qq|$Page<BR>|;
            }
            }
            else
            {
            if ($Order{Verified} ne "")
            {
            # camera pic
            print qq|<table style="margin-bottom: -.25em"><tr><td>|;
            print qq|<a target="$Game{Page}" href="$Pics/$Game{Page}.jpg">|;
            print qq|<img border=0 src="$Pics/Camera.gif" width="$Game{CameraW}"
            height="$Game{CameraH}"><BR>|;
            print qq|</a>|;
            print qq|</td><td>|;

            $Game{TButtonW}=$Game{ButtonW};
            $Game{TButtonH}=$Game{ButtonH};
            print qq|<img border=0 src="$Pics/$Game{Page}-0.gif"
            width="$Game{ButtonW}" height="$Game{ButtonH}"><BR>|;
            }
            else
            {
            print qq|$Page<BR>|;
            }
            }
            print qq|</td></tr></table>|;
            }
          • Rob Biedenharn
            ... absolutely! In your CGI script, you should reference the document root directory -- preferably by using an environement variable like $ENV {DOCUMENT_ROOT}
            Message 5 of 5 , Dec 15, 2006
            • 0 Attachment
              On Dec 15, 2006, at 1:22 PM, Lou Hernsen wrote:

              > the only thing i can think of at this point is that the path may be
              > different for the HTML code than the CGI code...
              > and I feeel i'm about to just sit here and try that.
              > that in the HTML the dir/dir/picture.jpg works
              > but in the CGI the path may have to be .../dir/dir/pictures.jpg
              > to back out of the cgi dirs and into tthe html dir???
              >
              > main dir
              > cgi dir
              > project dir (where my cgi is)
              > html dir
              > image.dir (where the picture is)
              >
              > maybe????????

              absolutely!

              In your CGI script, you should reference the document root directory
              -- preferably by using an environement variable like $ENV
              {DOCUMENT_ROOT} (which may come from Apache's mod_perl).

              Add a: print '<p>$ENV{DOCUMENT_ROOT} → ' . $ENV
              {DOCUMENT_ROOT} . "</p>\n";
              to see what this might be on your system. (Replace '→' with
              '=>' if you prefer)

              Note that not all web servers give you a way to determine the
              absolute location of the DOCUMENT_ROOT.

              -Rob

              Rob Biedenharn http://agileconsultingllc.com
              Rob@...
            Your message has been successfully submitted and would be delivered to recipients shortly.