Hey guys. I'm using the mirror() routine from LWP::Simple on the Mac. All
works wonderfully under MacPerl *until* I try to make a Mac runtime. Then
the mirror() doesn't work. get() works fine and as expected.

Case in point. This script compiles fine and spits out the file contents:

 use strict;
 use LWP;
 use LWP::Simple;
 use IO::Socket;
 my $url = "http://www.disobey.com/valid-file.txt";
 my $results = get($url);
 print $results;

However, this one works perfectly interpreted:

 #!/usr/bin/perl -w

 use strict;
 use LWP;
 use LWP::Simple;
 use IO::Socket;
 my $url = "http://www.disobey.com/valid-file.txt";
 my $file = "Splooge:Desktop Folder:valid-file.txt";
 mirror($url, $file) or print "Hey! $! / $@";

But does not work as a runtime. I added URI/_foreign.pm, _generic.pm and
_query.pm to the TEXT resource of the MacApp (as instructed in various
FAQs) - running it still does not create the version.txt file though. I
also get *no* output from the runtime.

Okkk. Welp, how about adding this, you say, right after the modules?

 open(STDERR, ">&STDOUT") or die "Couldn't redirect STDERR to STDOUT: $!";

Still no output. Hmf. Okkk. Checkpoints before and after the mirror...

 print STDOUT "Before the mirror...";
 mirror($url, $file) or print "Hey! $! / $@";
 print STDOUT "After the mirror...";

Nicely, I get:

 Before the mirror...After the mirror...

So. Uh. Why isn't the mirror happening? Catching the response from mirror():

 Before the mirror...After the mirror...Mirror's response: 501.

According to HTTP::Status, a 501 is RC_NOT_IMPLEMENTED. Um. Ok. I'm not
sure what's happening here. The script works perfectly from the "command
line" as it were, but as soon as I try to make a Mac runtime, it doesn't
work. Doing a search on the net shows stuff about "setting full path to the
saved file" (which I do), "getting the latest cpan's" (I've grabbed the
latest libwww-perl as well as the latest URI), and other things that didn't
pan out.

Two questions:

  1) Why doesn't this work?
  2) Has anyone written a mirror implementation in non-module Perl?

-- 
Morbus Iff

    ()       We have SuperMorbus - able to leap tall servers in a single
   <\/>      bound, faster than a speeding packet, stronger than 128 bit
   _/\_       encryption. Defender of Truth, Justice and Devil Shat...
                   Devil Shat: <http://www.disobey.com/devilshat/>

-04--- <\/> ---- <http://www.disobey.com/> --- Bad Ascii, Short Notice ----

Reply via email to