Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi all

I am trying to check if a file (image exists on another server - the line below doesn't work - anyone know if it is possible?
if (!-e "http://www.servername.com/images/imagename.jpg") { print "does not exist"; } else { print "exists"; }

Replies are listed 'Best First'.
Re: checking if a file / image exists on another server
by chromatic (Archbishop) on Sep 16, 2003 at 17:55 UTC

    Untested, but it's called LWP::Simple for a reason:

    use LWP::Simple; if (head( 'http://www.example.com/images/imagename.jpg' )) { print "exists!\n"; } else { print "does not exist!\n"; }
      perlfect! thanks
Re: checking if a file / image exists on another server
by shenme (Priest) on Sep 16, 2003 at 17:46 UTC
    Can't ... resist ...
    if ( -e "arecibo://life.outer.space/signals/beep-beep.au") { print "exists! SETI, eat your heart out" } else { print "does not exist"; }

      I'm not sure if that operator is capable of doing it that way. Giving it an address without using some form of module to translate/connect/make sense of the address, it probably just checks the current directory of execution for a file with the name of that address.

      Below is a test...