File Coverage

blib/lib/CPAN/FTP.pm
Criterion Covered Total %
statement 161 628 25.6
branch 54 404 13.3
condition 15 143 10.4
subroutine 18 27 66.6
pod 0 9 0.0
total 248 1211 20.4


line stmt bran cond sub pod time code
1             # -*- Mode: cperl; coding: utf-8; cperl-indent-level: 4 -*-
2             # vim: ts=4 sts=4 sw=4:
3             package CPAN::FTP;
4 13     13   91 use strict;
  13         26  
  13         399  
5              
6 13     13   2811 use Errno ();
  13         8549  
  13         301  
7 13     13   75 use Fcntl qw(:flock);
  13         23  
  13         2057  
8 13     13   100 use File::Basename qw(dirname);
  13         24  
  13         1320  
9 13     13   89 use File::Path qw(mkpath);
  13         28  
  13         792  
10 13     13   4821 use CPAN::FTP::netrc;
  13         34  
  13         424  
11 13     13   78 use vars qw($connect_to_internet_ok $Ua $Thesite $ThesiteURL $Themethod);
  13         28  
  13         932  
12              
13             @CPAN::FTP::ISA = qw(CPAN::Debug);
14              
15 13         96222 use vars qw(
16             $VERSION
17 13     13   73 );
  13         24  
18             $VERSION = "5.5012";
19              
20             sub _plus_append_open {
21 0     0   0 my($fh, $file) = @_;
22 0         0 my $parent_dir = dirname $file;
23 0         0 mkpath $parent_dir;
24 0         0 my($cnt);
25 0         0 until (open $fh, "+>>$file") {
26 0 0 0     0 next if exists &Errno::EAGAIN && $! == &Errno::EAGAIN; # don't increment on EAGAIN
27 0 0       0 $CPAN::Frontend->mydie("Could not open '$file' after 10000 tries: $!") if ++$cnt > 100000;
28 0         0 sleep 0.0001;
29 0         0 mkpath $parent_dir;
30             }
31             }
32              
33             #-> sub CPAN::FTP::ftp_statistics
34             # if they want to rewrite, they need to pass in a filehandle
35             sub _ftp_statistics {
36 0     0   0 my($self,$fh) = @_;
37 0         0 my $ftpstats_size = $CPAN::Config->{ftpstats_size};
38 0 0 0     0 return if defined $ftpstats_size && $ftpstats_size <= 0;
39 0 0       0 my $locktype = $fh ? LOCK_EX : LOCK_SH;
40             # XXX On Windows flock() implements mandatory locking, so we can
41             # XXX only use shared locking to still allow _yaml_load_file() to
42             # XXX read from the file using a different filehandle.
43 0 0       0 $locktype = LOCK_SH if $^O eq "MSWin32";
44              
45 0   0     0 $fh ||= FileHandle->new;
46 0         0 my $file = File::Spec->catfile($CPAN::Config->{cpan_home},"FTPstats.yml");
47 0         0 _plus_append_open($fh,$file);
48 0         0 my $sleep = 1;
49 0         0 my $waitstart;
50 0         0 while (!CPAN::_flock($fh, $locktype|LOCK_NB)) {
51 0   0     0 $waitstart ||= localtime();
52 0 0       0 if ($sleep>3) {
53 0         0 my $now = localtime();
54 0         0 $CPAN::Frontend->mywarn("$now: waiting for read lock on '$file' (since $waitstart)\n");
55             }
56 0         0 sleep($sleep); # this sleep must not be overridden;
57             # Frontend->mysleep with AUTOMATED_TESTING has
58             # provoked complete lock contention on my NFS
59 0 0       0 if ($sleep <= 6) {
60 0         0 $sleep+=0.5;
61             } else {
62             # retry to get a fresh handle. If it is NFS and the handle is stale, we will never get an flock
63 0         0 _plus_append_open($fh, $file);
64             }
65             }
66 0         0 my $stats = eval { CPAN->_yaml_loadfile($file); };
  0         0  
67 0 0       0 if ($@) {
68 0 0       0 if (ref $@) {
69 0 0       0 if (ref $@ eq "CPAN::Exception::yaml_not_installed") {
    0          
70 0         0 chomp $@;
71 0         0 $CPAN::Frontend->myprintonce("Warning (usually harmless): $@\n");
72 0         0 return;
73             } elsif (ref $@ eq "CPAN::Exception::yaml_process_error") {
74 0         0 my $time = time;
75 0         0 my $to = "$file.$time";
76 0         0 $CPAN::Frontend->mywarn("Error reading '$file': $@
77             Trying to stash it away as '$to' to prevent further interruptions.
78             You may want to remove that file later.\n");
79             # may fail because somebody else has moved it away in the meantime:
80 0 0       0 rename $file, $to or $CPAN::Frontend->mywarn("Could not rename '$file' to '$to': $!\n");
81 0         0 return;
82             }
83             } else {
84 0         0 $CPAN::Frontend->mydie($@);
85             }
86             }
87 0         0 CPAN::_flock($fh, LOCK_UN);
88 0         0 return $stats->[0];
89             }
90              
91             #-> sub CPAN::FTP::_mytime
92             sub _mytime () {
93 6 50   6   21 if (CPAN->has_inst("Time::HiRes")) {
94 6         48 return Time::HiRes::time();
95             } else {
96 0         0 return time;
97             }
98             }
99              
100             #-> sub CPAN::FTP::_new_stats
101             sub _new_stats {
102 3     3   7 my($self,$file) = @_;
103 3         10 my $ret = {
104             file => $file,
105             attempts => [],
106             start => _mytime,
107             };
108 3         8 $ret;
109             }
110              
111             #-> sub CPAN::FTP::_add_to_statistics
112             sub _add_to_statistics {
113 3     3   8 my($self,$stats) = @_;
114 3         13 my $yaml_module = CPAN::_yaml_module();
115 3 50       8 $self->debug("yaml_module[$yaml_module]") if $CPAN::DEBUG;
116 3 50       8 if ($CPAN::META->has_inst($yaml_module)) {
117 0         0 $stats->{thesiteurl} = $ThesiteURL;
118 0         0 $stats->{end} = CPAN::FTP::_mytime();
119 0         0 my $fh = FileHandle->new;
120 0         0 my $time = time;
121 0         0 my $sdebug = 0;
122 0         0 my @debug;
123 0 0       0 @debug = $time if $sdebug;
124 0         0 my $fullstats = $self->_ftp_statistics($fh);
125 0 0 0     0 close $fh if $fh && defined(fileno($fh));
126 0   0     0 $fullstats->{history} ||= [];
127 0 0       0 push @debug, scalar @{$fullstats->{history}} if $sdebug;
  0         0  
128 0 0       0 push @debug, time if $sdebug;
129 0         0 push @{$fullstats->{history}}, $stats;
  0         0  
130             # YAML.pm 0.62 is unacceptably slow with 999;
131             # YAML::Syck 0.82 has no noticable performance problem with 999;
132 0         0 my $ftpstats_size = $CPAN::Config->{ftpstats_size};
133 0 0       0 $ftpstats_size = 99 unless defined $ftpstats_size;
134 0   0     0 my $ftpstats_period = $CPAN::Config->{ftpstats_period} || 14;
135 0   0     0 while (
      0        
136 0 0       0 @{$fullstats->{history} || []}
137             &&
138             (
139             @{$fullstats->{history}} > $ftpstats_size
140             || $time - $fullstats->{history}[0]{start} > 86400*$ftpstats_period
141             )
142             ) {
143 0         0 shift @{$fullstats->{history}}
  0         0  
144             }
145 0 0       0 push @debug, scalar @{$fullstats->{history}} if $sdebug;
  0         0  
146 0 0       0 push @debug, time if $sdebug;
147 0 0       0 push @debug, scalar localtime($fullstats->{history}[0]{start}) if $sdebug;
148             # need no eval because if this fails, it is serious
149 0         0 my $sfile = File::Spec->catfile($CPAN::Config->{cpan_home},"FTPstats.yml");
150 0         0 CPAN->_yaml_dumpfile("$sfile.$$",$fullstats);
151 0 0       0 if ( $sdebug ) {
152 0         0 local $CPAN::DEBUG = 512; # FTP
153 0         0 push @debug, time;
154 0         0 CPAN->debug(sprintf("DEBUG history: before_read[%d]before[%d]at[%d]".
155             "after[%d]at[%d]oldest[%s]dumped backat[%d]",
156             @debug,
157             ));
158             }
159             # Win32 cannot rename a file to an existing filename
160 0 0 0     0 unlink($sfile) if ($^O eq 'MSWin32' or $^O eq 'os2');
161 0 0       0 _copy_stat($sfile, "$sfile.$$") if -e $sfile;
162 0 0       0 rename "$sfile.$$", $sfile
163             or $CPAN::Frontend->mywarn("Could not rename '$sfile.$$' to '$sfile': $!\nGiving up\n");
164             }
165             }
166              
167             # Copy some stat information (owner, group, mode and) from one file to
168             # another.
169             # This is a utility function which might be moved to a utility repository.
170             #-> sub CPAN::FTP::_copy_stat
171             sub _copy_stat {
172 0     0   0 my($src, $dest) = @_;
173 0         0 my @stat = stat($src);
174 0 0       0 if (!@stat) {
175 0         0 $CPAN::Frontend->mywarn("Can't stat '$src': $!\n");
176 0         0 return;
177             }
178              
179 0         0 eval {
180 0 0       0 chmod $stat[2], $dest
181             or $CPAN::Frontend->mywarn("Can't chmod '$dest' to " . sprintf("0%o", $stat[2]) . ": $!\n");
182             };
183 0 0       0 warn $@ if $@;
184 0         0 eval {
185             chown $stat[4], $stat[5], $dest
186 0 0       0 or do {
187 0         0 my $save_err = $!; # otherwise it's lost in the get... calls
188 0         0 $CPAN::Frontend->mywarn("Can't chown '$dest' to " .
189             (getpwuid($stat[4]))[0] . "/" .
190             (getgrgid($stat[5]))[0] . ": $save_err\n"
191             );
192             };
193             };
194 0 0       0 warn $@ if $@;
195             }
196              
197             # if file is CHECKSUMS, suggest the place where we got the file to be
198             # checked from, maybe only for young files?
199             #-> sub CPAN::FTP::_recommend_url_for
200             sub _recommend_url_for {
201 3     3   9 my($self, $file, $urllist) = @_;
202 3 50       17 if ($file =~ s|/CHECKSUMS(.gz)?$||) {
203 0         0 my $fullstats = $self->_ftp_statistics();
204 0   0     0 my $history = $fullstats->{history} || [];
205 0         0 while (my $last = pop @$history) {
206 0 0       0 last if $last->{end} - time > 3600; # only young results are interesting
207 0 0       0 next unless $last->{file}; # dirname of nothing dies!
208 0 0       0 next unless $file eq dirname($last->{file});
209 0         0 return $last->{thesiteurl};
210             }
211             }
212 3 50 33     11 if ($CPAN::Config->{randomize_urllist}
213             &&
214             rand(1) < $CPAN::Config->{randomize_urllist}
215             ) {
216 0         0 $urllist->[int rand scalar @$urllist];
217             } else {
218 3         11 return ();
219             }
220             }
221              
222             #-> sub CPAN::FTP::_get_urllist
223             sub _get_urllist {
224 3     3   8 my($self, $with_defaults) = @_;
225 3   50     19 $with_defaults ||= 0;
226 3 50       7 CPAN->debug("with_defaults[$with_defaults]") if $CPAN::DEBUG;
227              
228 3   50     8 $CPAN::Config->{urllist} ||= [];
229 3 50       10 unless (ref $CPAN::Config->{urllist} eq 'ARRAY') {
230 0         0 $CPAN::Frontend->mywarn("Malformed urllist; ignoring. Configuration file corrupt?\n");
231 0         0 $CPAN::Config->{urllist} = [];
232             }
233 3 50       4 my @urllist = grep { defined $_ and length $_ } @{$CPAN::Config->{urllist}};
  3         19  
  3         7  
234 3 50       10 push @urllist, @CPAN::Defaultsites if $with_defaults;
235 3         6 for my $u (@urllist) {
236 3 50       10 CPAN->debug("u[$u]") if $CPAN::DEBUG;
237 3 50       27 if (UNIVERSAL::can($u,"text")) {
238 0 0       0 $u->{TEXT} .= "/" unless substr($u->{TEXT},-1) eq "/";
239             } else {
240 3 50       17 $u .= "/" unless substr($u,-1) eq "/";
241 3         24 $u = CPAN::URL->new(TEXT => $u, FROM => "USER");
242             }
243             }
244 3         7 \@urllist;
245             }
246              
247             #-> sub CPAN::FTP::ftp_get ;
248             sub ftp_get {
249 0     0 0 0 my($class,$host,$dir,$file,$target) = @_;
250 0 0       0 $class->debug(
251             qq[Going to fetch file [$file] from dir [$dir]
252             on host [$host] as local [$target]\n]
253             ) if $CPAN::DEBUG;
254 0         0 my $ftp = Net::FTP->new($host);
255 0 0       0 unless ($ftp) {
256 0         0 $CPAN::Frontend->mywarn(" Could not connect to host '$host' with Net::FTP\n");
257 0         0 return;
258             }
259 0 0       0 return 0 unless defined $ftp;
260 0 0       0 $ftp->debug(1) if $CPAN::DEBUG{'FTP'} & $CPAN::DEBUG;
261 0         0 $class->debug(qq[Going to login("anonymous","$Config::Config{cf_email}")]);
262 0 0       0 unless ( $ftp->login("anonymous",$Config::Config{'cf_email'}) ) {
263 0         0 my $msg = $ftp->message;
264 0         0 $CPAN::Frontend->mywarn(" Couldn't login on $host: $msg\n");
265 0         0 return;
266             }
267 0 0       0 unless ( $ftp->cwd($dir) ) {
268 0         0 my $msg = $ftp->message;
269 0         0 $CPAN::Frontend->mywarn(" Couldn't cwd $dir: $msg\n");
270 0         0 return;
271             }
272 0         0 $ftp->binary;
273 0 0       0 $class->debug(qq[Going to ->get("$file","$target")\n]) if $CPAN::DEBUG;
274 0 0       0 unless ( $ftp->get($file,$target) ) {
275 0         0 my $msg = $ftp->message;
276 0         0 $CPAN::Frontend->mywarn(" Couldn't fetch $file from $host: $msg\n");
277 0         0 return;
278             }
279 0         0 $ftp->quit; # it's ok if this fails
280 0         0 return 1;
281             }
282              
283             # If more accuracy is wanted/needed, Chris Leach sent me this patch...
284              
285             # > *** /install/perl/live/lib/CPAN.pm- Wed Sep 24 13:08:48 1997
286             # > --- /tmp/cp Wed Sep 24 13:26:40 1997
287             # > ***************
288             # > *** 1562,1567 ****
289             # > --- 1562,1580 ----
290             # > return 1 if substr($url,0,4) eq "file";
291             # > return 1 unless $url =~ m|://([^/]+)|;
292             # > my $host = $1;
293             # > + my $proxy = $CPAN::Config->{'http_proxy'} || $ENV{'http_proxy'};
294             # > + if ($proxy) {
295             # > + $proxy =~ m|://([^/:]+)|;
296             # > + $proxy = $1;
297             # > + my $noproxy = $CPAN::Config->{'no_proxy'} || $ENV{'no_proxy'};
298             # > + if ($noproxy) {
299             # > + if ($host !~ /$noproxy$/) {
300             # > + $host = $proxy;
301             # > + }
302             # > + } else {
303             # > + $host = $proxy;
304             # > + }
305             # > + }
306             # > require Net::Ping;
307             # > return 1 unless $Net::Ping::VERSION >= 2;
308             # > my $p;
309              
310              
311             #-> sub CPAN::FTP::localize ;
312             sub localize {
313 3     3 0 10 my($self,$file,$aslocal,$force,$with_defaults) = @_;
314 3   50     11 $force ||= 0;
315 3 50       10 Carp::croak( "Usage: ->localize(cpan_file,as_local_file[,\$force])" )
316             unless defined $aslocal;
317 3 50       9 if ($CPAN::DEBUG){
318 0         0 require Carp;
319 0         0 my $longmess = Carp::longmess();
320 0         0 $self->debug("file[$file] aslocal[$aslocal] force[$force] carplongmess[$longmess]");
321             }
322 3 50       12 if ($^O eq 'MacOS') {
323             # Comment by AK on 2000-09-03: Uniq short filenames would be
324             # available in CHECKSUMS file
325 0         0 my($name, $path) = File::Basename::fileparse($aslocal, '');
326 0 0       0 if (length($name) > 31) {
327 0         0 $name =~ s/(
328             \.(
329             readme(\.(gz|Z))? |
330             (tar\.)?(gz|Z) |
331             tgz |
332             zip |
333             pm\.(gz|Z)
334             )
335             )$//x;
336 0         0 my $suf = $1;
337 0         0 my $size = 31 - length($suf);
338 0         0 while (length($name) > $size) {
339 0         0 chop $name;
340             }
341 0         0 $name .= $suf;
342 0         0 $aslocal = File::Spec->catfile($path, $name);
343             }
344             }
345              
346 3 0 33     26 if (-f $aslocal && -r _ && !($force & 1)) {
      33        
347 0         0 my $size;
348 0 0       0 if ($size = -s $aslocal) {
349 0 0       0 $self->debug("aslocal[$aslocal]size[$size]") if $CPAN::DEBUG;
350 0         0 return $aslocal;
351             } else {
352             # empty file from a previous unsuccessful attempt to download it
353 0 0       0 unlink $aslocal or
354             $CPAN::Frontend->mydie("Found a zero-length '$aslocal' that I ".
355             "could not remove.");
356             }
357             }
358 3         11 my($maybe_restore) = 0;
359 3 50       25 if (-f $aslocal) {
360 0         0 rename $aslocal, "$aslocal.bak$$";
361 0         0 $maybe_restore++;
362             }
363              
364 3         190 my($aslocal_dir) = dirname($aslocal);
365             # Inheritance is not easier to manage than a few if/else branches
366 3 50       19 if ($CPAN::META->has_usable('LWP::UserAgent')) {
367 0 0       0 unless ($Ua) {
368 0         0 CPAN::LWP::UserAgent->config;
369 0         0 eval {$Ua = CPAN::LWP::UserAgent->new;}; # Why is has_usable still not fit enough?
  0         0  
370 0 0       0 if ($@) {
371 0 0       0 $CPAN::Frontend->mywarn("CPAN::LWP::UserAgent->new dies with $@\n")
372             if $CPAN::DEBUG;
373             } else {
374 0         0 my($var);
375             $Ua->proxy('ftp', $var)
376 0 0 0     0 if $var = $CPAN::Config->{ftp_proxy} || $ENV{ftp_proxy};
377             $Ua->proxy('http', $var)
378 0 0 0     0 if $var = $CPAN::Config->{http_proxy} || $ENV{http_proxy};
379             $Ua->no_proxy($var)
380 0 0 0     0 if $var = $CPAN::Config->{no_proxy} || $ENV{no_proxy};
381             }
382             }
383             }
384 3         10 for my $prx (qw(ftp_proxy http_proxy no_proxy)) {
385 9 50       21 $ENV{$prx} = $CPAN::Config->{$prx} if $CPAN::Config->{$prx};
386             }
387              
388             # Try the list of urls for each single object. We keep a record
389             # where we did get a file from
390 3         6 my(@reordered,$last);
391 3         18 my $ccurllist = $self->_get_urllist($with_defaults);
392 3         6 $last = $#$ccurllist;
393 3 50       12 if ($force & 2) { # local cpans probably out of date, don't reorder
394 3         13 @reordered = (0..$last);
395             } else {
396             @reordered =
397             sort {
398 0 0 0     0 (substr($ccurllist->[$b],0,4) eq "file")
  0         0  
399             <=>
400             (substr($ccurllist->[$a],0,4) eq "file")
401             or
402             defined($ThesiteURL)
403             and
404             ($ccurllist->[$b] eq $ThesiteURL)
405             <=>
406             ($ccurllist->[$a] eq $ThesiteURL)
407             } 0..$last;
408             }
409 3         5 my(@levels);
410 3   100     15 $Themethod ||= "";
411 3 50       11 $self->debug("Themethod[$Themethod]reordered[@reordered]") if $CPAN::DEBUG;
412 3         35 my @all_levels = (
413             ["dleasy", "file"],
414             ["dleasy"],
415             ["dlhard"],
416             ["dlhardest"],
417             ["dleasy", "http","defaultsites"],
418             ["dlhard", "http","defaultsites"],
419             ["dleasy", "ftp", "defaultsites"],
420             ["dlhard", "ftp", "defaultsites"],
421             ["dlhardest","", "defaultsites"],
422             );
423 3 100       8 if ($Themethod) {
424 2         3 @levels = grep {$_->[0] eq $Themethod} @all_levels;
  18         27  
425 2         4 push @levels, grep {$_->[0] ne $Themethod} @all_levels;
  18         51  
426             } else {
427 1         2 @levels = @all_levels;
428             }
429 3 50       11 @levels = qw/dleasy/ if $^O eq 'MacOS';
430 3         19 my($levelno);
431             local $ENV{FTP_PASSIVE} =
432             exists $CPAN::Config->{ftp_passive} ?
433 3 50       55 $CPAN::Config->{ftp_passive} : 1;
434 3         7 my $ret;
435 3         17 my $stats = $self->_new_stats($file);
436 3         13 for ($CPAN::Config->{connect_to_internet_ok}) {
437 3 50 33     20 $connect_to_internet_ok = $_ if not defined $connect_to_internet_ok and defined $_;
438             }
439 3         10 LEVEL: for $levelno (0..$#levels) {
440 3         8 my $level_tuple = $levels[$levelno];
441 3         8 my($level,$scheme,$sitetag) = @$level_tuple;
442 3 50 33     15 $self->mymkpath($aslocal_dir) unless $scheme && "file" eq $scheme;
443 3   33     9 my $defaultsites = $sitetag && $sitetag eq "defaultsites" && !@$ccurllist;
444 3         5 my @urllist;
445 3 50       6 if ($defaultsites) {
446 0 0       0 unless (defined $connect_to_internet_ok) {
447             $CPAN::Frontend->myprint(sprintf qq{
448             I would like to connect to one of the following sites to get '%s':
449              
450             %s
451             },
452             $file,
453 0         0 join("",map { " ".$_->text."\n" } @CPAN::Defaultsites),
  0         0  
454             );
455 0         0 my $answer = CPAN::Shell::colorable_makemaker_prompt("Is it OK to try to connect to the Internet?", "yes");
456 0 0       0 if ($answer =~ /^y/i) {
457 0         0 $connect_to_internet_ok = 1;
458             } else {
459 0         0 $connect_to_internet_ok = 0;
460             }
461             }
462 0 0       0 if ($connect_to_internet_ok) {
463 0         0 @urllist = @CPAN::Defaultsites;
464             } else {
465 0         0 my $sleep = 2;
466             # the tricky thing about dying here is that everybody
467             # believes that calls to exists() or all_objects() are
468             # safe.
469 0         0 require CPAN::Exception::blocked_urllist;
470 0         0 die CPAN::Exception::blocked_urllist->new;
471             }
472             } else { # ! $defaultsites
473 3 50       21 my @host_seq = $level =~ /dleasy/ ?
474             @reordered : 0..$last; # reordered has file and $Thesiteurl first
475 3         7 @urllist = map { $ccurllist->[$_] } @host_seq;
  3         10  
476             }
477 3 50       12 $self->debug("synth. urllist[@urllist]") if $CPAN::DEBUG;
478 3         12 my $aslocal_tempfile = $aslocal . ".tmp" . $$;
479 3 50       15 if (my $recommend = $self->_recommend_url_for($file,\@urllist)) {
480 0         0 @urllist = grep { $_ ne $recommend } @urllist;
  0         0  
481 0         0 unshift @urllist, $recommend;
482             }
483 3 50       7 $self->debug("synth. urllist[@urllist]") if $CPAN::DEBUG;
484 3         15 $ret = $self->hostdlxxx($level,$scheme,\@urllist,$file,$aslocal_tempfile,$stats);
485 3 50       9 if ($ret) {
486 3 50       6 CPAN->debug("ret[$ret]aslocal[$aslocal]") if $CPAN::DEBUG;
487 3 50 33     51 if ($ret eq $aslocal_tempfile) {
    50          
488             # if we got it exactly as we asked for, only then we
489             # want to rename
490 0 0       0 rename $aslocal_tempfile, $aslocal
491             or $CPAN::Frontend->mydie("Error while trying to rename ".
492             "'$ret' to '$aslocal': $!");
493 0         0 $ret = $aslocal;
494             }
495             elsif (-f $ret && $scheme eq 'file' ) {
496             # it's a local file, so there's nothing left to do, we
497             # let them read from where it is
498             }
499 3         7 $Themethod = $level;
500 3         6 my $now = time;
501             # utime $now, $now, $aslocal; # too bad, if we do that, we
502             # might alter a local mirror
503 3 50       5 $self->debug("level[$level]") if $CPAN::DEBUG;
504 3         11 last LEVEL;
505             } else {
506 0         0 unlink $aslocal_tempfile;
507 0 0       0 last if $CPAN::Signal; # need to cleanup
508             }
509             }
510 3 50       6 if ($ret) {
511 3         36 $stats->{filesize} = -s $ret;
512             }
513 3 50       10 $self->debug("before _add_to_statistics") if $CPAN::DEBUG;
514 3         17 $self->_add_to_statistics($stats);
515 3 50       7 $self->debug("after _add_to_statistics") if $CPAN::DEBUG;
516 3 50       8 if ($ret) {
517 3         30 unlink "$aslocal.bak$$";
518 3         46 return $ret;
519             }
520 0 0       0 unless ($CPAN::Signal) {
521 0         0 my(@mess);
522 0         0 local $" = " ";
523 0 0       0 if (@{$CPAN::Config->{urllist}}) {
  0         0  
524             push @mess,
525             qq{Please check, if the URLs I found in your configuration file \(}.
526 0         0 join(", ", @{$CPAN::Config->{urllist}}).
  0         0  
527             qq{\) are valid.};
528             } else {
529 0         0 push @mess, qq{Your urllist is empty!};
530             }
531 0         0 push @mess, qq{The urllist can be edited.},
532             qq{E.g. with 'o conf urllist push ftp://myurl/'};
533 0         0 $CPAN::Frontend->mywarn(Text::Wrap::wrap("","","@mess"). "\n\n");
534 0         0 $CPAN::Frontend->mydie("Could not fetch $file\n");
535             }
536 0 0       0 if ($maybe_restore) {
537 0         0 rename "$aslocal.bak$$", $aslocal;
538 0         0 $CPAN::Frontend->myprint("Trying to get away with old file:\n" .
539             $self->ls($aslocal) . "\n");
540 0         0 return $aslocal;
541             }
542 0         0 return;
543             }
544              
545             sub mymkpath {
546 0     0 0 0 my($self, $aslocal_dir) = @_;
547 0         0 mkpath($aslocal_dir);
548 0 0       0 $CPAN::Frontend->mywarn(qq{Warning: You are not allowed to write into }.
549             qq{directory "$aslocal_dir".
550             I\'ll continue, but if you encounter problems, they may be due
551             to insufficient permissions.\n}) unless -w $aslocal_dir;
552             }
553              
554             sub hostdlxxx {
555 3     3 0 5 my $self = shift;
556 3         5 my $level = shift;
557 3         4 my $scheme = shift;
558 3         4 my $h = shift;
559 3 50       57 $h = [ grep /^\Q$scheme\E:/, @$h ] if $scheme;
560 3         7 my $method = "host$level";
561 3         17 $self->$method($h, @_);
562             }
563              
564             sub _set_attempt {
565 3     3   9 my($self,$stats,$method,$url) = @_;
566 3         4 push @{$stats->{attempts}}, {
  3         10  
567             method => $method,
568             start => _mytime,
569             url => $url,
570             };
571             }
572              
573             # package CPAN::FTP;
574             sub hostdleasy { #called from hostdlxxx
575 3     3 0 12 my($self,$host_seq,$file,$aslocal,$stats) = @_;
576 3         8 my($ro_url);
577 3         13 HOSTEASY: for $ro_url (@$host_seq) {
578 3         10 $self->_set_attempt($stats,"dleasy",$ro_url);
579 3         10 my $url = "$ro_url$file";
580 3 50       10 $self->debug("localizing perlish[$url]") if $CPAN::DEBUG;
581 3 50       15 if ($url =~ /^file:/) {
582 3         4 my $l;
583 3 50       8 if ($CPAN::META->has_inst('URI::URL')) {
584 3         15 my $u = URI::URL->new($url);
585 3         5284 $l = $u->file;
586             } else { # works only on Unix, is poorly constructed, but
587             # hopefully better than nothing.
588             # RFC 1738 says fileurl BNF is
589             # fileurl = "file://" [ host | "localhost" ] "/" fpath
590             # Thanks to "Mark D. Baushke" for
591             # the code
592 0         0 ($l = $url) =~ s|^file://[^/]*/|/|; # discard the host part
593 0         0 $l =~ s|^file:||; # assume they
594             # meant
595             # file://localhost
596 0 0 0     0 $l =~ s|^/||s
597             if ! -f $l && $l =~ m|^/\w:|; # e.g. /P:
598             }
599 3 50       2286 $self->debug("local file[$l]") if $CPAN::DEBUG;
600 3 50 33     84 if ( -f $l && -r _) {
601 0         0 $ThesiteURL = $ro_url;
602 0         0 return $l;
603             }
604             # If request is for a compressed file and we can find the
605             # uncompressed file also, return the path of the uncompressed file
606             # otherwise, decompress it and return the resulting path
607 3 50 0     27 if ($l =~ /(.+)\.gz$/) {
    0          
    0          
608 3         10 my $ungz = $1;
609 3 50 33     62 if ( -f $ungz && -r _) {
    0 0        
610 3         9 $ThesiteURL = $ro_url;
611 3         29 return $ungz;
612             }
613             elsif (-f $l && -r _) {
614 0         0 eval { CPAN::Tarzip->new($l)->gunzip($aslocal) };
  0         0  
615 0 0 0     0 if ( -f $aslocal && -s _) {
    0          
    0          
616 0         0 $ThesiteURL = $ro_url;
617 0         0 return $aslocal;
618             }
619             elsif (! -s $aslocal) {
620 0         0 unlink $aslocal;
621             }
622             elsif (-f $l) {
623 0 0       0 $CPAN::Frontend->mywarn("Error decompressing '$l': $@\n")
624             if $@;
625 0         0 return;
626             }
627             }
628             }
629             # Otherwise, return the local file path if it exists
630             elsif ( -f $l && -r _) {
631 0         0 $ThesiteURL = $ro_url;
632 0         0 return $l;
633             }
634             # If we can't find it, but there is a compressed version
635             # of it, then decompress it
636             elsif (-f "$l.gz") {
637 0 0       0 $self->debug("found compressed $l.gz") if $CPAN::DEBUG;
638 0         0 eval { CPAN::Tarzip->new("$l.gz")->gunzip($aslocal) };
  0         0  
639 0 0       0 if ( -f $aslocal) {
640 0         0 $ThesiteURL = $ro_url;
641 0         0 return $aslocal;
642             }
643             else {
644 0 0       0 $CPAN::Frontend->mywarn("Error decompressing '$l': $@\n")
645             if $@;
646 0         0 return;
647             }
648             }
649 0         0 $CPAN::Frontend->mywarn("Could not find '$l'\n");
650             }
651 0 0       0 $self->debug("it was not a file URL") if $CPAN::DEBUG;
652 0 0 0     0 if ($CPAN::META->has_usable('LWP')) {
    0          
653 0         0 $CPAN::Frontend->myprint("Fetching with LWP:\n$url\n");
654 0 0       0 unless ($Ua) {
655 0         0 CPAN::LWP::UserAgent->config;
656 0         0 eval { $Ua = CPAN::LWP::UserAgent->new; };
  0         0  
657 0 0       0 if ($@) {
658 0         0 $CPAN::Frontend->mywarn("CPAN::LWP::UserAgent->new dies with $@\n");
659             }
660             }
661 0         0 my $res = $Ua->mirror($url, $aslocal);
662 0 0       0 if ($res->is_success) {
    0          
663 0         0 $ThesiteURL = $ro_url;
664 0         0 my $now = time;
665 0         0 utime $now, $now, $aslocal; # download time is more
666             # important than upload
667             # time
668 0         0 return $aslocal;
669             } elsif ($url !~ /\.gz(?!\n)\Z/) {
670 0         0 my $gzurl = "$url.gz";
671 0         0 $CPAN::Frontend->myprint("Fetching with LWP:\n$gzurl\n");
672 0         0 $res = $Ua->mirror($gzurl, "$aslocal.gz");
673 0 0       0 if ($res->is_success) {
674 0 0       0 if (eval {CPAN::Tarzip->new("$aslocal.gz")->gunzip($aslocal)}) {
  0         0  
675 0         0 $ThesiteURL = $ro_url;
676 0         0 return $aslocal;
677             }
678             }
679             } else {
680 0         0 $CPAN::Frontend->myprint(sprintf(
681             "LWP failed with code[%s] message[%s]\n",
682             $res->code,
683             $res->message,
684             ));
685             # Alan Burlison informed me that in firewall environments
686             # Net::FTP can still succeed where LWP fails. So we do not
687             # skip Net::FTP anymore when LWP is available.
688             }
689             } elsif ($url =~ /^http:/i && $CPAN::META->has_usable('HTTP::Tiny')) {
690 0         0 require CPAN::HTTP::Client;
691             my $chc = CPAN::HTTP::Client->new(
692             proxy => $CPAN::Config->{http_proxy} || $ENV{http_proxy},
693             no_proxy => $CPAN::Config->{no_proxy} || $ENV{no_proxy},
694 0   0     0 );
      0        
695 0 0       0 for my $try ( $url, ( $url !~ /\.gz(?!\n)\Z/ ? "$url.gz" : () ) ) {
696 0         0 $CPAN::Frontend->myprint("Fetching with HTTP::Tiny:\n$try\n");
697 0         0 my $res = eval { $chc->mirror($try, $aslocal) };
  0         0  
698 0 0 0     0 if ( $res && $res->{success} ) {
    0 0        
    0 0        
699 0         0 $ThesiteURL = $ro_url;
700 0         0 my $now = time;
701 0         0 utime $now, $now, $aslocal; # download time is more
702             # important than upload
703             # time
704 0         0 return $aslocal;
705             }
706             elsif ( $res && $res->{status} ne '599') {
707             $CPAN::Frontend->myprint(sprintf(
708             "HTTP::Tiny failed with code[%s] message[%s]\n",
709             $res->{status},
710             $res->{reason},
711             )
712 0         0 );
713             }
714             elsif ( $res && $res->{status} eq '599') {
715             $CPAN::Frontend->myprint(sprintf(
716             "HTTP::Tiny failed with an internal error: %s\n",
717             $res->{content},
718             )
719 0         0 );
720             }
721             else {
722 0   0     0 my $err = $@ || 'Unknown error';
723 0         0 $CPAN::Frontend->myprint(sprintf(
724             "Error downloading with HTTP::Tiny: %s\n", $err
725             )
726             );
727             }
728             }
729             }
730 0 0       0 return if $CPAN::Signal;
731 0 0       0 if ($url =~ m|^ftp://(.*?)/(.*)/(.*)|) {
732             # that's the nice and easy way thanks to Graham
733 0 0       0 $self->debug("recognized ftp") if $CPAN::DEBUG;
734 0         0 my($host,$dir,$getfile) = ($1,$2,$3);
735 0 0       0 if ($CPAN::META->has_usable('Net::FTP')) {
736 0         0 $dir =~ s|/+|/|g;
737 0         0 $CPAN::Frontend->myprint("Fetching with Net::FTP:\n$url\n");
738 0 0       0 $self->debug("getfile[$getfile]dir[$dir]host[$host]" .
739             "aslocal[$aslocal]") if $CPAN::DEBUG;
740 0 0       0 if (CPAN::FTP->ftp_get($host,$dir,$getfile,$aslocal)) {
741 0         0 $ThesiteURL = $ro_url;
742 0         0 return $aslocal;
743             }
744 0 0       0 if ($aslocal !~ /\.gz(?!\n)\Z/) {
745 0         0 my $gz = "$aslocal.gz";
746 0         0 $CPAN::Frontend->myprint("Fetching with Net::FTP\n$url.gz\n");
747 0 0 0     0 if (CPAN::FTP->ftp_get($host,
748             $dir,
749             "$getfile.gz",
750             $gz) &&
751 0         0 eval{CPAN::Tarzip->new($gz)->gunzip($aslocal)}
752             ) {
753 0         0 $ThesiteURL = $ro_url;
754 0         0 return $aslocal;
755             }
756             }
757             # next HOSTEASY;
758             } else {
759 0 0       0 CPAN->debug("Net::FTP does not count as usable atm") if $CPAN::DEBUG;
760             }
761             }
762 0 0 0     0 if (
763             UNIVERSAL::can($ro_url,"text")
764             and
765             $ro_url->{FROM} eq "USER"
766             ) {
767             ##address #17973: default URLs should not try to override
768             ##user-defined URLs just because LWP is not available
769 0         0 my $ret = $self->hostdlhard([$ro_url],$file,$aslocal,$stats);
770 0 0       0 return $ret if $ret;
771             }
772 0 0       0 return if $CPAN::Signal;
773             }
774             }
775              
776             # package CPAN::FTP;
777             sub hostdlhard {
778 0     0 0 0 my($self,$host_seq,$file,$aslocal,$stats) = @_;
779              
780             # Came back if Net::FTP couldn't establish connection (or
781             # failed otherwise) Maybe they are behind a firewall, but they
782             # gave us a socksified (or other) ftp program...
783              
784 0         0 my($ro_url);
785 0   0     0 my($devnull) = $CPAN::Config->{devnull} || "";
786             # < /dev/null ";
787 0         0 my($aslocal_dir) = dirname($aslocal);
788 0         0 mkpath($aslocal_dir);
789 0         0 my $some_dl_success = 0;
790 0         0 my $any_attempt = 0;
791 0         0 HOSTHARD: for $ro_url (@$host_seq) {
792 0         0 $self->_set_attempt($stats,"dlhard",$ro_url);
793 0         0 my $url = "$ro_url$file";
794 0         0 my($proto,$host,$dir,$getfile);
795              
796             # Courtesy Mark Conty mark_conty@cargill.com change from
797             # if ($url =~ m|^ftp://(.*?)/(.*)/(.*)|) {
798             # to
799 0 0       0 if ($url =~ m|^([^:]+)://(.*?)/(.*)/(.*)|) {
800             # proto not yet used
801 0         0 ($proto,$host,$dir,$getfile) = ($1,$2,$3,$4);
802             } else {
803 0         0 next HOSTHARD; # who said, we could ftp anything except ftp?
804             }
805 0 0       0 next HOSTHARD if $proto eq "file"; # file URLs would have had
806             # success above. Likely a bogus URL
807              
808             # making at least one attempt against a host
809 0         0 $any_attempt++;
810              
811 0 0       0 $self->debug("localizing funkyftpwise[$url]") if $CPAN::DEBUG;
812              
813             # Try the most capable first and leave ncftp* for last as it only
814             # does FTP.
815 0         0 my $proxy_vars = $self->_proxy_vars($ro_url);
816 0         0 DLPRG: for my $f (qw(curl wget lynx ncftpget ncftp)) {
817 0         0 my $funkyftp = CPAN::HandleConfig->safe_quote($CPAN::Config->{$f});
818 0 0       0 next DLPRG unless defined $funkyftp;
819 0 0       0 next DLPRG if $funkyftp =~ /^\s*$/;
820              
821 0         0 my($src_switch) = "";
822 0         0 my($chdir) = "";
823 0         0 my($stdout_redir) = " > \"$aslocal\"";
824 0 0       0 if ($f eq "lynx") {
    0          
    0          
    0          
    0          
825 0         0 $src_switch = " -source";
826             } elsif ($f eq "ncftp") {
827 0 0       0 next DLPRG unless $url =~ m{\Aftp://};
828 0         0 $src_switch = " -c";
829             } elsif ($f eq "wget") {
830 0         0 $src_switch = " -O \"$aslocal\"";
831 0         0 $stdout_redir = "";
832             } elsif ($f eq 'curl') {
833 0         0 $src_switch = ' -L -f -s -S --netrc-optional';
834 0 0       0 if ($proxy_vars->{http_proxy}) {
835 0         0 $src_switch .= qq{ -U "$proxy_vars->{proxy_user}:$proxy_vars->{proxy_pass}" -x "$proxy_vars->{http_proxy}"};
836             }
837             } elsif ($f eq "ncftpget") {
838 0 0       0 next DLPRG unless $url =~ m{\Aftp://};
839 0         0 $chdir = "cd $aslocal_dir && ";
840 0         0 $stdout_redir = "";
841             }
842             $CPAN::Frontend->myprint(
843 0         0 qq[
844             Trying with
845             $funkyftp$src_switch
846             to get
847             $url
848             ]);
849 0         0 my($system) =
850             "$chdir$funkyftp$src_switch \"$url\" $devnull$stdout_redir";
851 0 0       0 $self->debug("system[$system]") if $CPAN::DEBUG;
852 0         0 my($wstatus) = system($system);
853 0 0       0 if ($f eq "lynx") {
854             # lynx returns 0 when it fails somewhere
855 0 0       0 if (-s $aslocal) {
856 0         0 my $content = do { local *FH;
  0         0  
857 0 0       0 open FH, $aslocal or die;
858 0         0 local $/;
859 0         0 };
860 0 0       0 if ($content =~ /^<.*([45]|Error [45])/si) { </td> </tr> <tr> <td class="h" > <a name="861">861</a> </td> <td class="c0" > <a href="#865"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s"> $CPAN::Frontend->mywarn(qq{ </td> </tr> <tr> <td class="h" > <a name="862">862</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> No success, the file that lynx has downloaded looks like an error message: </td> </tr> <tr> <td class="h" > <a name="863">863</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> $content </td> </tr> <tr> <td class="h" > <a name="864">864</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> }); </td> </tr> <tr> <td class="h" > <a name="865">865</a> </td> <td class="c0" > <a href="#866"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s"> $CPAN::Frontend->mysleep(1); </td> </tr> <tr> <td class="h" > <a name="866">866</a> </td> <td class="c0" > <a href="#868"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s"> next DLPRG; </td> </tr> <tr> <td class="h" > <a name="867">867</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="868">868</a> </td> <td class="c0" > <a href="#870"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s"> $some_dl_success++; </td> </tr> <tr> <td class="h" > <a name="869">869</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } else { </td> </tr> <tr> <td class="h" > <a name="870">870</a> </td> <td class="c0" > <a href="#873"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s"> $CPAN::Frontend->myprint(qq{ </td> </tr> <tr> <td class="h" > <a name="871">871</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> No success, the file that lynx has downloaded is an empty file. </td> </tr> <tr> <td class="h" > <a name="872">872</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> }); </td> </tr> <tr> <td class="h" > <a name="873">873</a> </td> <td class="c0" > <a href="#876"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s"> next DLPRG; </td> </tr> <tr> <td class="h" > <a name="874">874</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="875">875</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="876">876</a> </td> <td class="c0" > <a href="#877"> 0 </a> </td> <td class="c0" > <a href="blib-lib-CPAN-FTP-pm--branch.html#876-1"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s"> if ($wstatus == 0) { </td> </tr> <tr> <td class="h" > <a name="877">877</a> </td> <td class="c0" > <a href="#879"> 0 </a> </td> <td class="c0" > <a href="blib-lib-CPAN-FTP-pm--branch.html#877-1"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s"> if (-s $aslocal) { </td> </tr> <tr> <td class="h" > <a name="878">878</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> # Looks good </td> </tr> <tr> <td class="h" > <a name="879">879</a> </td> <td class="c0" > <a href="#881"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s"> $some_dl_success++; </td> </tr> <tr> <td class="h" > <a name="880">880</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="881">881</a> </td> <td class="c0" > <a href="#882"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s"> $ThesiteURL = $ro_url; </td> </tr> <tr> <td class="h" > <a name="882">882</a> </td> <td class="c0" > <a href="#884"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s"> return $aslocal; </td> </tr> <tr> <td class="h" > <a name="883">883</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } else { </td> </tr> <tr> <td class="h" > <a name="884">884</a> </td> <td class="c0" > <a href="#885"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s"> my $estatus = $wstatus >> 8; </td> </tr> <tr> <td class="h" > <a name="885">885</a> </td> <td class="c0" > <a href="#888"> 0 </a> </td> <td class="c0" > <a href="blib-lib-CPAN-FTP-pm--branch.html#885-1"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s"> my $size = -f $aslocal ? </td> </tr> <tr> <td class="h" > <a name="886">886</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> ", left\n$aslocal with size ".-s _ : </td> </tr> <tr> <td class="h" > <a name="887">887</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> "\nWarning: expected file [$aslocal] doesn't exist"; </td> </tr> <tr> <td class="h" > <a name="888">888</a> </td> <td class="c0" > <a href="#893"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s"> $CPAN::Frontend->myprint(qq{ </td> </tr> <tr> <td class="h" > <a name="889">889</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> Function system("$system") </td> </tr> <tr> <td class="h" > <a name="890">890</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> returned status $estatus (wstat $wstatus)$size </td> </tr> <tr> <td class="h" > <a name="891">891</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> }); </td> </tr> <tr> <td class="h" > <a name="892">892</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="893">893</a> </td> <td class="c0" > <a href="#896"> 0 </a> </td> <td class="c0" > <a href="blib-lib-CPAN-FTP-pm--branch.html#893-1"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s"> return if $CPAN::Signal; </td> </tr> <tr> <td class="h" > <a name="894">894</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } # download/transfer programs (DLPRG) </td> </tr> <tr> <td class="h" > <a name="895">895</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } # host </td> </tr> <tr> <td class="h" > <a name="896">896</a> </td> <td class="c0" > <a href="#897"> 0 </a> </td> <td class="c0" > <a href="blib-lib-CPAN-FTP-pm--branch.html#896-1"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s"> return unless $any_attempt; </td> </tr> <tr> <td class="h" > <a name="897">897</a> </td> <td class="c0" > <a href="#898"> 0 </a> </td> <td class="c0" > <a href="blib-lib-CPAN-FTP-pm--branch.html#897-1"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s"> if ($some_dl_success) { </td> </tr> <tr> <td class="h" > <a name="898">898</a> </td> <td class="c0" > <a href="#900"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s"> $CPAN::Frontend->mywarn("Warning: doesn't seem we had substantial success downloading '$aslocal'. Don't know how to proceed.\n"); </td> </tr> <tr> <td class="h" > <a name="899">899</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } else { </td> </tr> <tr> <td class="h" > <a name="900">900</a> </td> <td class="c0" > <a href="#902"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s"> $CPAN::Frontend->mywarn("Warning: no success downloading '$aslocal'. Giving up on it.\n"); </td> </tr> <tr> <td class="h" > <a name="901">901</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="902">902</a> </td> <td class="c0" > <a href="#923"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s"> return; </td> </tr> <tr> <td class="h" > <a name="903">903</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="904">904</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="905">905</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> #-> CPAN::FTP::_proxy_vars </td> </tr> <tr> <td class="h" > <a name="906">906</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> sub _proxy_vars { </td> </tr> <tr> <td class="h" > <a name="907">907</a> </td> <td class="c3" > 2 </td> <td >   </td> <td >   </td> <td class="c3" > <a href="blib-lib-CPAN-FTP-pm--subroutine.html#907-1"> 2 </a> </td> <td >   </td> <td > 4001 </td> <td class="s"> my($self,$url) = @_; </td> </tr> <tr> <td class="h" > <a name="908">908</a> </td> <td class="c3" > 2 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 5 </td> <td class="s"> my $ret = +{}; </td> </tr> <tr> <td class="h" > <a name="909">909</a> </td> <td class="c3" > 2 </td> <td >   </td> <td class="c0" > <a href="blib-lib-CPAN-FTP-pm--condition.html#909-1"> 33 </a> </td> <td >   </td> <td >   </td> <td > 8 </td> <td class="s"> my $http_proxy = $CPAN::Config->{'http_proxy'} || $ENV{'http_proxy'}; </td> </tr> <tr> <td class="h" > <a name="910">910</a> </td> <td class="c3" > 2 </td> <td class="c0" > <a href="blib-lib-CPAN-FTP-pm--branch.html#910-1"> 50 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td > 5 </td> <td class="s"> if ($http_proxy) { </td> </tr> <tr> <td class="h" > <a name="911">911</a> </td> <td class="c3" > 2 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 12 </td> <td class="s"> my($host) = $url =~ m|://([^/:]+)|; </td> </tr> <tr> <td class="h" > <a name="912">912</a> </td> <td class="c3" > 2 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 4 </td> <td class="s"> my $want_proxy = 1; </td> </tr> <tr> <td class="h" > <a name="913">913</a> </td> <td class="c3" > 2 </td> <td >   </td> <td class="c0" > <a href="blib-lib-CPAN-FTP-pm--condition.html#913-1"> 0 </a> </td> <td >   </td> <td >   </td> <td > 6 </td> <td class="s"> my $noproxy = $CPAN::Config->{'no_proxy'} || $ENV{'no_proxy'} || ""; </td> </tr> <tr> <td class="h" > <a name="914">914</a> </td> <td class="c3" > 2 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 6 </td> <td class="s"> my @noproxy = split /\s*,\s*/, $noproxy; </td> </tr> <tr> <td class="h" > <a name="915">915</a> </td> <td class="c3" > 2 </td> <td class="c0" > <a href="blib-lib-CPAN-FTP-pm--branch.html#915-1"> 50 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td > 6 </td> <td class="s"> if ($host) { </td> </tr> <tr> <td class="h" > <a name="916">916</a> </td> <td class="c3" > 2 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 4 </td> <td class="s"> DOMAIN: for my $domain (@noproxy) { </td> </tr> <tr> <td class="h" > <a name="917">917</a> </td> <td class="c3" > 2 </td> <td class="c3" > <a href="blib-lib-CPAN-FTP-pm--branch.html#917-1"> 100 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td > 35 </td> <td class="s"> if ($host =~ /\Q$domain\E$/) { # cf. LWP::UserAgent </td> </tr> <tr> <td class="h" > <a name="918">918</a> </td> <td class="c3" > 1 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 4 </td> <td class="s"> $want_proxy = 0; </td> </tr> <tr> <td class="h" > <a name="919">919</a> </td> <td class="c3" > 1 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 2 </td> <td class="s"> last DOMAIN; </td> </tr> <tr> <td class="h" > <a name="920">920</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="921">921</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="922">922</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } else { </td> </tr> <tr> <td class="h" > <a name="923">923</a> </td> <td class="c0" > <a href="#940"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s"> $CPAN::Frontend->mywarn(" Could not determine host from http_proxy '$http_proxy'\n"); </td> </tr> <tr> <td class="h" > <a name="924">924</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="925">925</a> </td> <td class="c3" > 2 </td> <td class="c3" > <a href="blib-lib-CPAN-FTP-pm--branch.html#925-1"> 100 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td > 6 </td> <td class="s"> if ($want_proxy) { </td> </tr> <tr> <td class="h" > <a name="926">926</a> </td> <td class="c3" > 1 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 19 </td> <td class="s"> my($user, $pass) = </td> </tr> <tr> <td class="h" > <a name="927">927</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> CPAN::HTTP::Credentials->get_proxy_credentials(); </td> </tr> <tr> <td class="h" > <a name="928">928</a> </td> <td class="c3" > 1 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 5 </td> <td class="s"> $ret = { </td> </tr> <tr> <td class="h" > <a name="929">929</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> proxy_user => $user, </td> </tr> <tr> <td class="h" > <a name="930">930</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> proxy_pass => $pass, </td> </tr> <tr> <td class="h" > <a name="931">931</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> http_proxy => $http_proxy </td> </tr> <tr> <td class="h" > <a name="932">932</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> }; </td> </tr> <tr> <td class="h" > <a name="933">933</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="934">934</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="935">935</a> </td> <td class="c3" > 2 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 5 </td> <td class="s"> return $ret; </td> </tr> <tr> <td class="h" > <a name="936">936</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="937">937</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="938">938</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> # package CPAN::FTP; </td> </tr> <tr> <td class="h" > <a name="939">939</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> sub hostdlhardest { </td> </tr> <tr> <td class="h" > <a name="940">940</a> </td> <td class="c0" > <a href="#942"> 0 </a> </td> <td >   </td> <td >   </td> <td class="c0" > <a href="blib-lib-CPAN-FTP-pm--subroutine.html#940-1"> 0 </a> </td> <td class="c0" > <a href="blib-lib-CPAN-FTP-pm--subroutine.html#940-1"> 0 </a> </td> <td >   </td> <td class="s"> my($self,$host_seq,$file,$aslocal,$stats) = @_; </td> </tr> <tr> <td class="h" > <a name="941">941</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="942">942</a> </td> <td class="c0" > <a href="#943"> 0 </a> </td> <td class="c0" > <a href="blib-lib-CPAN-FTP-pm--branch.html#942-1"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> return unless @$host_seq; </td> </tr> <tr> <td class="h" > <a name="943">943</a> </td> <td class="c0" > <a href="#944"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> my($ro_url); </td> </tr> <tr> <td class="h" > <a name="944">944</a> </td> <td class="c0" > <a href="#945"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> my($aslocal_dir) = dirname($aslocal); </td> </tr> <tr> <td class="h" > <a name="945">945</a> </td> <td class="c0" > <a href="#946"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> mkpath($aslocal_dir); </td> </tr> <tr> <td class="h" > <a name="946">946</a> </td> <td class="c0" > <a href="#947"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> my $ftpbin = $CPAN::Config->{ftp}; </td> </tr> <tr> <td class="h" > <a name="947">947</a> </td> <td class="c0" > <a href="#948"> 0 </a> </td> <td class="c0" > <a href="blib-lib-CPAN-FTP-pm--branch.html#947-1"> 0 </a> </td> <td class="c0" > <a href="blib-lib-CPAN-FTP-pm--condition.html#947-1"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> unless ($ftpbin && length $ftpbin && MM->maybe_command($ftpbin)) { </td> </tr> <tr> <td class="h" > <a > </a> </td> <td >   </td> <td >   </td> <td class="c0" > <a href="blib-lib-CPAN-FTP-pm--condition.html#-2"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="948">948</a> </td> <td class="c0" > <a href="#949"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> $CPAN::Frontend->myprint("No external ftp command available\n\n"); </td> </tr> <tr> <td class="h" > <a name="949">949</a> </td> <td class="c0" > <a href="#951"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> return; </td> </tr> <tr> <td class="h" > <a name="950">950</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="951">951</a> </td> <td class="c0" > <a href="#964"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> $CPAN::Frontend->mywarn(qq{ </td> </tr> <tr> <td class="h" > <a name="952">952</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> As a last resort we now switch to the external ftp command '$ftpbin' </td> </tr> <tr> <td class="h" > <a name="953">953</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> to get '$aslocal'. </td> </tr> <tr> <td class="h" > <a name="954">954</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="955">955</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> Doing so often leads to problems that are hard to diagnose. </td> </tr> <tr> <td class="h" > <a name="956">956</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="957">957</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> If you're the victim of such problems, please consider unsetting the </td> </tr> <tr> <td class="h" > <a name="958">958</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> ftp config variable with </td> </tr> <tr> <td class="h" > <a name="959">959</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="960">960</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> o conf ftp "" </td> </tr> <tr> <td class="h" > <a name="961">961</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> o conf commit </td> </tr> <tr> <td class="h" > <a name="962">962</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="963">963</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> }); </td> </tr> <tr> <td class="h" > <a name="964">964</a> </td> <td class="c0" > <a href="#965"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> $CPAN::Frontend->mysleep(2); </td> </tr> <tr> <td class="h" > <a name="965">965</a> </td> <td class="c0" > <a href="#966"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> HOSTHARDEST: for $ro_url (@$host_seq) { </td> </tr> <tr> <td class="h" > <a name="966">966</a> </td> <td class="c0" > <a href="#967"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> $self->_set_attempt($stats,"dlhardest",$ro_url); </td> </tr> <tr> <td class="h" > <a name="967">967</a> </td> <td class="c0" > <a href="#968"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> my $url = "$ro_url$file"; </td> </tr> <tr> <td class="h" > <a name="968">968</a> </td> <td class="c0" > <a href="#969"> 0 </a> </td> <td class="c0" > <a href="blib-lib-CPAN-FTP-pm--branch.html#968-1"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> $self->debug("localizing ftpwise[$url]") if $CPAN::DEBUG; </td> </tr> <tr> <td class="h" > <a name="969">969</a> </td> <td class="c0" > <a href="#970"> 0 </a> </td> <td class="c0" > <a href="blib-lib-CPAN-FTP-pm--branch.html#969-1"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> unless ($url =~ m|^ftp://(.*?)/(.*)/(.*)|) { </td> </tr> <tr> <td class="h" > <a name="970">970</a> </td> <td class="c0" > <a href="#972"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> next; </td> </tr> <tr> <td class="h" > <a name="971">971</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="972">972</a> </td> <td class="c0" > <a href="#973"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> my($host,$dir,$getfile) = ($1,$2,$3); </td> </tr> <tr> <td class="h" > <a name="973">973</a> </td> <td class="c0" > <a href="#974"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> my $timestamp = 0; </td> </tr> <tr> <td class="h" > <a name="974">974</a> </td> <td class="c0" > <a href="#976"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> my($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime, </td> </tr> <tr> <td class="h" > <a name="975">975</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> $ctime,$blksize,$blocks) = stat($aslocal); </td> </tr> <tr> <td class="h" > <a name="976">976</a> </td> <td class="c0" > <a href="#977"> 0 </a> </td> <td >   </td> <td class="c0" > <a href="blib-lib-CPAN-FTP-pm--condition.html#976-1"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> $timestamp = $mtime ||= 0; </td> </tr> <tr> <td class="h" > <a name="977">977</a> </td> <td class="c0" > <a href="#978"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> my($netrc) = CPAN::FTP::netrc->new; </td> </tr> <tr> <td class="h" > <a name="978">978</a> </td> <td class="c0" > <a href="#979"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> my($netrcfile) = $netrc->netrc; </td> </tr> <tr> <td class="h" > <a name="979">979</a> </td> <td class="c0" > <a href="#980"> 0 </a> </td> <td class="c0" > <a href="blib-lib-CPAN-FTP-pm--branch.html#979-1"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> my($verbose) = $CPAN::DEBUG{'FTP'} & $CPAN::DEBUG ? " -v" : ""; </td> </tr> <tr> <td class="h" > <a name="980">980</a> </td> <td class="c0" > <a href="#981"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> my $targetfile = File::Basename::basename($aslocal); </td> </tr> <tr> <td class="h" > <a name="981">981</a> </td> <td class="c0" > <a href="#982"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> my(@dialog); </td> </tr> <tr> <td class="h" > <a name="982">982</a> </td> <td class="c0" > <a href="#992"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> push( </td> </tr> <tr> <td class="h" > <a name="983">983</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> @dialog, </td> </tr> <tr> <td class="h" > <a name="984">984</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> "lcd $aslocal_dir", </td> </tr> <tr> <td class="h" > <a name="985">985</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> "cd /", </td> </tr> <tr> <td class="h" > <a name="986">986</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> map("cd $_", split /\//, $dir), # RFC 1738 </td> </tr> <tr> <td class="h" > <a name="987">987</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> "bin", </td> </tr> <tr> <td class="h" > <a name="988">988</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> "passive", </td> </tr> <tr> <td class="h" > <a name="989">989</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> "get $getfile $targetfile", </td> </tr> <tr> <td class="h" > <a name="990">990</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> "quit" </td> </tr> <tr> <td class="h" > <a name="991">991</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> ); </td> </tr> <tr> <td class="h" > <a name="992">992</a> </td> <td class="c0" > <a href="#993"> 0 </a> </td> <td class="c0" > <a href="blib-lib-CPAN-FTP-pm--branch.html#992-1"> 0 </a> </td> <td class="c0" > <a href="blib-lib-CPAN-FTP-pm--condition.html#992-1"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> if (! $netrcfile) { </td> </tr> <tr> <td class="h" > <a > </a> </td> <td >   </td> <td class="c0" > <a href="blib-lib-CPAN-FTP-pm--branch.html#-2"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="993">993</a> </td> <td class="c0" > <a href="#995"> 0 </a> </td> <td class="c0" > <a href="blib-lib-CPAN-FTP-pm--branch.html#993-1"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> CPAN->debug("No ~/.netrc file found") if $CPAN::DEBUG; </td> </tr> <tr> <td class="h" > <a name="994">994</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } elsif ($netrc->hasdefault || $netrc->contains($host)) { </td> </tr> <tr> <td class="h" > <a name="995">995</a> </td> <td class="c0" > <a href="#998"> 0 </a> </td> <td class="c0" > <a href="blib-lib-CPAN-FTP-pm--branch.html#995-1"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> CPAN->debug(sprintf("hasdef[%d]cont($host)[%d]", </td> </tr> <tr> <td class="h" > <a name="996">996</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> $netrc->hasdefault, </td> </tr> <tr> <td class="h" > <a name="997">997</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> $netrc->contains($host))) if $CPAN::DEBUG; </td> </tr> <tr> <td class="h" > <a name="998">998</a> </td> <td class="c0" > <a href="#999"> 0 </a> </td> <td class="c0" > <a href="blib-lib-CPAN-FTP-pm--branch.html#998-1"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> if ($netrc->protected) { </td> </tr> <tr> <td class="h" > <a name="999">999</a> </td> <td class="c0" > <a href="# "> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> my $dialog = join "", map { " $_\n" } @dialog; </td> </tr> <tr> <td class="h" > <a > </a> </td> <td class="c0" > <a href="#1000"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="1000">1000</a> </td> <td class="c0" > <a href="#1001"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> my $netrc_explain; </td> </tr> <tr> <td class="h" > <a name="1001">1001</a> </td> <td class="c0" > <a href="#1002"> 0 </a> </td> <td class="c0" > <a href="blib-lib-CPAN-FTP-pm--branch.html#1001-1"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> if ($netrc->contains($host)) { </td> </tr> <tr> <td class="h" > <a name="1002">1002</a> </td> <td class="c0" > <a href="#1005"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> $netrc_explain = "Relying that your .netrc entry for '$host' ". </td> </tr> <tr> <td class="h" > <a name="1003">1003</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> "manages the login"; </td> </tr> <tr> <td class="h" > <a name="1004">1004</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } else { </td> </tr> <tr> <td class="h" > <a name="1005">1005</a> </td> <td class="c0" > <a href="#1008"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> $netrc_explain = "Relying that your default .netrc entry ". </td> </tr> <tr> <td class="h" > <a name="1006">1006</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> "manages the login"; </td> </tr> <tr> <td class="h" > <a name="1007">1007</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="1008">1008</a> </td> <td class="c0" > <a href="#1016"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> $CPAN::Frontend->myprint(qq{ </td> </tr> <tr> <td class="h" > <a name="1009">1009</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> Trying with external ftp to get </td> </tr> <tr> <td class="h" > <a name="1010">1010</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> '$url' </td> </tr> <tr> <td class="h" > <a name="1011">1011</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> $netrc_explain </td> </tr> <tr> <td class="h" > <a name="1012">1012</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> Sending the dialog </td> </tr> <tr> <td class="h" > <a name="1013">1013</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> $dialog </td> </tr> <tr> <td class="h" > <a name="1014">1014</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="1015">1015</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> ); </td> </tr> <tr> <td class="h" > <a name="1016">1016</a> </td> <td class="c0" > <a href="#1018"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> $self->talk_ftp("$ftpbin$verbose $host", </td> </tr> <tr> <td class="h" > <a name="1017">1017</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> @dialog); </td> </tr> <tr> <td class="h" > <a name="1018">1018</a> </td> <td class="c0" > <a href="#1020"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size, </td> </tr> <tr> <td class="h" > <a name="1019">1019</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> $atime,$mtime,$ctime,$blksize,$blocks) = stat($aslocal); </td> </tr> <tr> <td class="h" > <a name="1020">1020</a> </td> <td class="c0" > <a href="#1021"> 0 </a> </td> <td >   </td> <td class="c0" > <a href="blib-lib-CPAN-FTP-pm--condition.html#1020-1"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> $mtime ||= 0; </td> </tr> <tr> <td class="h" > <a name="1021">1021</a> </td> <td class="c0" > <a href="#1022"> 0 </a> </td> <td class="c0" > <a href="blib-lib-CPAN-FTP-pm--branch.html#1021-1"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> if ($mtime > $timestamp) { </td> </tr> <tr> <td class="h" > <a name="1022">1022</a> </td> <td class="c0" > <a href="#1023"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> $CPAN::Frontend->myprint("GOT $aslocal\n"); </td> </tr> <tr> <td class="h" > <a name="1023">1023</a> </td> <td class="c0" > <a href="#1024"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> $ThesiteURL = $ro_url; </td> </tr> <tr> <td class="h" > <a name="1024">1024</a> </td> <td class="c0" > <a href="#1026"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> return $aslocal; </td> </tr> <tr> <td class="h" > <a name="1025">1025</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } else { </td> </tr> <tr> <td class="h" > <a name="1026">1026</a> </td> <td class="c0" > <a href="#1028"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> $CPAN::Frontend->myprint("Hmm... Still failed!\n"); </td> </tr> <tr> <td class="h" > <a name="1027">1027</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="1028">1028</a> </td> <td class="c0" > <a href="#1030"> 0 </a> </td> <td class="c0" > <a href="blib-lib-CPAN-FTP-pm--branch.html#1028-1"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> return if $CPAN::Signal; </td> </tr> <tr> <td class="h" > <a name="1029">1029</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } else { </td> </tr> <tr> <td class="h" > <a name="1030">1030</a> </td> <td class="c0" > <a href="#1034"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> $CPAN::Frontend->mywarn(qq{Your $netrcfile is not }. </td> </tr> <tr> <td class="h" > <a name="1031">1031</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> qq{correctly protected.\n}); </td> </tr> <tr> <td class="h" > <a name="1032">1032</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="1033">1033</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } else { </td> </tr> <tr> <td class="h" > <a name="1034">1034</a> </td> <td class="c0" > <a href="#1041"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> $CPAN::Frontend->mywarn("Your ~/.netrc neither contains $host </td> </tr> <tr> <td class="h" > <a name="1035">1035</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> nor does it have a default entry\n"); </td> </tr> <tr> <td class="h" > <a name="1036">1036</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="1037">1037</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="1038">1038</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> # OK, they don't have a valid ~/.netrc. Use 'ftp -n' </td> </tr> <tr> <td class="h" > <a name="1039">1039</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> # then and login manually to host, using e-mail as </td> </tr> <tr> <td class="h" > <a name="1040">1040</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> # password. </td> </tr> <tr> <td class="h" > <a name="1041">1041</a> </td> <td class="c0" > <a href="#1042"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> $CPAN::Frontend->myprint(qq{Issuing "$ftpbin$verbose -n"\n}); </td> </tr> <tr> <td class="h" > <a name="1042">1042</a> </td> <td class="c0" > <a href="#1047"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> unshift( </td> </tr> <tr> <td class="h" > <a name="1043">1043</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> @dialog, </td> </tr> <tr> <td class="h" > <a name="1044">1044</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> "open $host", </td> </tr> <tr> <td class="h" > <a name="1045">1045</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> "user anonymous $Config::Config{'cf_email'}" </td> </tr> <tr> <td class="h" > <a name="1046">1046</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> ); </td> </tr> <tr> <td class="h" > <a name="1047">1047</a> </td> <td class="c0" > <a href="# "> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> my $dialog = join "", map { " $_\n" } @dialog; </td> </tr> <tr> <td class="h" > <a > </a> </td> <td class="c0" > <a href="#1048"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="1048">1048</a> </td> <td class="c0" > <a href="#1055"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> $CPAN::Frontend->myprint(qq{ </td> </tr> <tr> <td class="h" > <a name="1049">1049</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> Trying with external ftp to get </td> </tr> <tr> <td class="h" > <a name="1050">1050</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> $url </td> </tr> <tr> <td class="h" > <a name="1051">1051</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> Sending the dialog </td> </tr> <tr> <td class="h" > <a name="1052">1052</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> $dialog </td> </tr> <tr> <td class="h" > <a name="1053">1053</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="1054">1054</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> ); </td> </tr> <tr> <td class="h" > <a name="1055">1055</a> </td> <td class="c0" > <a href="#1056"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> $self->talk_ftp("$ftpbin$verbose -n", @dialog); </td> </tr> <tr> <td class="h" > <a name="1056">1056</a> </td> <td class="c0" > <a href="#1058"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size, </td> </tr> <tr> <td class="h" > <a name="1057">1057</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> $atime,$mtime,$ctime,$blksize,$blocks) = stat($aslocal); </td> </tr> <tr> <td class="h" > <a name="1058">1058</a> </td> <td class="c0" > <a href="#1059"> 0 </a> </td> <td >   </td> <td class="c0" > <a href="blib-lib-CPAN-FTP-pm--condition.html#1058-1"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> $mtime ||= 0; </td> </tr> <tr> <td class="h" > <a name="1059">1059</a> </td> <td class="c0" > <a href="#1060"> 0 </a> </td> <td class="c0" > <a href="blib-lib-CPAN-FTP-pm--branch.html#1059-1"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> if ($mtime > $timestamp) { </td> </tr> <tr> <td class="h" > <a name="1060">1060</a> </td> <td class="c0" > <a href="#1061"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> $CPAN::Frontend->myprint("GOT $aslocal\n"); </td> </tr> <tr> <td class="h" > <a name="1061">1061</a> </td> <td class="c0" > <a href="#1062"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> $ThesiteURL = $ro_url; </td> </tr> <tr> <td class="h" > <a name="1062">1062</a> </td> <td class="c0" > <a href="#1064"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> return $aslocal; </td> </tr> <tr> <td class="h" > <a name="1063">1063</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } else { </td> </tr> <tr> <td class="h" > <a name="1064">1064</a> </td> <td class="c0" > <a href="#1066"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> $CPAN::Frontend->myprint("Bad luck... Still failed!\n"); </td> </tr> <tr> <td class="h" > <a name="1065">1065</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="1066">1066</a> </td> <td class="c0" > <a href="#1067"> 0 </a> </td> <td class="c0" > <a href="blib-lib-CPAN-FTP-pm--branch.html#1066-1"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> return if $CPAN::Signal; </td> </tr> <tr> <td class="h" > <a name="1067">1067</a> </td> <td class="c0" > <a href="#1068"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> $CPAN::Frontend->mywarn("Can't access URL $url.\n\n"); </td> </tr> <tr> <td class="h" > <a name="1068">1068</a> </td> <td class="c0" > <a href="#1074"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> $CPAN::Frontend->mysleep(2); </td> </tr> <tr> <td class="h" > <a name="1069">1069</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } # host </td> </tr> <tr> <td class="h" > <a name="1070">1070</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="1071">1071</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="1072">1072</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> # package CPAN::FTP; </td> </tr> <tr> <td class="h" > <a name="1073">1073</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> sub talk_ftp { </td> </tr> <tr> <td class="h" > <a name="1074">1074</a> </td> <td class="c0" > <a href="#1075"> 0 </a> </td> <td >   </td> <td >   </td> <td class="c0" > <a href="blib-lib-CPAN-FTP-pm--subroutine.html#1074-1"> 0 </a> </td> <td class="c0" > <a href="blib-lib-CPAN-FTP-pm--subroutine.html#1074-1"> 0 </a> </td> <td >   </td> <td class="s"> my($self,$command,@dialog) = @_; </td> </tr> <tr> <td class="h" > <a name="1075">1075</a> </td> <td class="c0" > <a href="#1076"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> my $fh = FileHandle->new; </td> </tr> <tr> <td class="h" > <a name="1076">1076</a> </td> <td class="c0" > <a href="#1077"> 0 </a> </td> <td class="c0" > <a href="blib-lib-CPAN-FTP-pm--branch.html#1076-1"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> $fh->open("|$command") or die "Couldn't open ftp: $!"; </td> </tr> <tr> <td class="h" > <a name="1077">1077</a> </td> <td class="c0" > <a href="# "> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> foreach (@dialog) { $fh->print("$_\n") } </td> </tr> <tr> <td class="h" > <a > </a> </td> <td class="c0" > <a href="#1078"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="1078">1078</a> </td> <td class="c0" > <a href="#1079"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> $fh->close; # Wait for process to complete </td> </tr> <tr> <td class="h" > <a name="1079">1079</a> </td> <td class="c0" > <a href="#1080"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> my $wstatus = $?; </td> </tr> <tr> <td class="h" > <a name="1080">1080</a> </td> <td class="c0" > <a href="#1081"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> my $estatus = $wstatus >> 8; </td> </tr> <tr> <td class="h" > <a name="1081">1081</a> </td> <td class="c0" > <a href="#1091"> 0 </a> </td> <td class="c0" > <a href="blib-lib-CPAN-FTP-pm--branch.html#1081-1"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> $CPAN::Frontend->myprint(qq{ </td> </tr> <tr> <td class="h" > <a name="1082">1082</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> Subprocess "|$command" </td> </tr> <tr> <td class="h" > <a name="1083">1083</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> returned status $estatus (wstat $wstatus) </td> </tr> <tr> <td class="h" > <a name="1084">1084</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> }) if $wstatus; </td> </tr> <tr> <td class="h" > <a name="1085">1085</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="1086">1086</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="1087">1087</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> # find2perl needs modularization, too, all the following is stolen </td> </tr> <tr> <td class="h" > <a name="1088">1088</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> # from there </td> </tr> <tr> <td class="h" > <a name="1089">1089</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> # CPAN::FTP::ls </td> </tr> <tr> <td class="h" > <a name="1090">1090</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> sub ls { </td> </tr> <tr> <td class="h" > <a name="1091">1091</a> </td> <td class="c0" > <a href="#1092"> 0 </a> </td> <td >   </td> <td >   </td> <td class="c0" > <a href="blib-lib-CPAN-FTP-pm--subroutine.html#1091-1"> 0 </a> </td> <td class="c0" > <a href="blib-lib-CPAN-FTP-pm--subroutine.html#1091-1"> 0 </a> </td> <td >   </td> <td class="s"> my($self,$name) = @_; </td> </tr> <tr> <td class="h" > <a name="1092">1092</a> </td> <td class="c0" > <a href="#1095"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$sizemm, </td> </tr> <tr> <td class="h" > <a name="1093">1093</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> $atime,$mtime,$ctime,$blksize,$blocks) = lstat($name); </td> </tr> <tr> <td class="h" > <a name="1094">1094</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="1095">1095</a> </td> <td class="c0" > <a href="#1096"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> my($perms,%user,%group); </td> </tr> <tr> <td class="h" > <a name="1096">1096</a> </td> <td class="c0" > <a href="#1098"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> my $pname = $name; </td> </tr> <tr> <td class="h" > <a name="1097">1097</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="1098">1098</a> </td> <td class="c0" > <a href="#1099"> 0 </a> </td> <td class="c0" > <a href="blib-lib-CPAN-FTP-pm--branch.html#1098-1"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> if ($blocks) { </td> </tr> <tr> <td class="h" > <a name="1099">1099</a> </td> <td class="c0" > <a href="#1102"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> $blocks = int(($blocks + 1) / 2); </td> </tr> <tr> <td class="h" > <a name="1100">1100</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="1101">1101</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> else { </td> </tr> <tr> <td class="h" > <a name="1102">1102</a> </td> <td class="c0" > <a href="#1105"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> $blocks = int(($sizemm + 1023) / 1024); </td> </tr> <tr> <td class="h" > <a name="1103">1103</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="1104">1104</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="1105">1105</a> </td> <td class="c0" > <a href="# "> 0 </a> </td> <td class="c0" > <a href="blib-lib-CPAN-FTP-pm--branch.html#1105-1"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> if (-f _) { $perms = '-'; } </td> </tr> <tr> <td class="h" > <a > </a> </td> <td class="c0" > <a href="#1106"> 0 </a> </td> <td class="c0" > <a href="blib-lib-CPAN-FTP-pm--branch.html#-2"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a > </a> </td> <td >   </td> <td class="c0" > <a href="blib-lib-CPAN-FTP-pm--branch.html#-3"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a > </a> </td> <td >   </td> <td class="c0" > <a href="blib-lib-CPAN-FTP-pm--branch.html#-4"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a > </a> </td> <td >   </td> <td class="c0" > <a href="blib-lib-CPAN-FTP-pm--branch.html#-5"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a > </a> </td> <td >   </td> <td class="c0" > <a href="blib-lib-CPAN-FTP-pm--branch.html#-6"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="1106">1106</a> </td> <td class="c0" > <a href="#1107"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> elsif (-d _) { $perms = 'd'; } </td> </tr> <tr> <td class="h" > <a name="1107">1107</a> </td> <td class="c0" > <a href="# "> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> elsif (-c _) { $perms = 'c'; $sizemm = &sizemm; } </td> </tr> <tr> <td class="h" > <a > </a> </td> <td class="c0" > <a href="#1108"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="1108">1108</a> </td> <td class="c0" > <a href="# "> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> elsif (-b _) { $perms = 'b'; $sizemm = &sizemm; } </td> </tr> <tr> <td class="h" > <a > </a> </td> <td class="c0" > <a href="#1109"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="1109">1109</a> </td> <td class="c0" > <a href="#1110"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> elsif (-p _) { $perms = 'p'; } </td> </tr> <tr> <td class="h" > <a name="1110">1110</a> </td> <td class="c0" > <a href="#1111"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> elsif (-S _) { $perms = 's'; } </td> </tr> <tr> <td class="h" > <a name="1111">1111</a> </td> <td class="c0" > <a href="# "> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> else { $perms = 'l'; $pname .= ' -> ' . readlink($_); } </td> </tr> <tr> <td class="h" > <a > </a> </td> <td class="c0" > <a href="#1113"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="1112">1112</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="1113">1113</a> </td> <td class="c0" > <a href="#1114"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> my(@rwx) = ('---','--x','-w-','-wx','r--','r-x','rw-','rwx'); </td> </tr> <tr> <td class="h" > <a name="1114">1114</a> </td> <td class="c0" > <a href="#1115"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> my(@moname) = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec); </td> </tr> <tr> <td class="h" > <a name="1115">1115</a> </td> <td class="c0" > <a href="#1116"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> my $tmpmode = $mode; </td> </tr> <tr> <td class="h" > <a name="1116">1116</a> </td> <td class="c0" > <a href="#1117"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> my $tmp = $rwx[$tmpmode & 7]; </td> </tr> <tr> <td class="h" > <a name="1117">1117</a> </td> <td class="c0" > <a href="#1118"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> $tmpmode >>= 3; </td> </tr> <tr> <td class="h" > <a name="1118">1118</a> </td> <td class="c0" > <a href="#1119"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> $tmp = $rwx[$tmpmode & 7] . $tmp; </td> </tr> <tr> <td class="h" > <a name="1119">1119</a> </td> <td class="c0" > <a href="#1120"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> $tmpmode >>= 3; </td> </tr> <tr> <td class="h" > <a name="1120">1120</a> </td> <td class="c0" > <a href="#1121"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> $tmp = $rwx[$tmpmode & 7] . $tmp; </td> </tr> <tr> <td class="h" > <a name="1121">1121</a> </td> <td class="c0" > <a href="#1122"> 0 </a> </td> <td class="c0" > <a href="blib-lib-CPAN-FTP-pm--branch.html#1121-1"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> substr($tmp,2,1) =~ tr/-x/Ss/ if -u _; </td> </tr> <tr> <td class="h" > <a name="1122">1122</a> </td> <td class="c0" > <a href="#1123"> 0 </a> </td> <td class="c0" > <a href="blib-lib-CPAN-FTP-pm--branch.html#1122-1"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> substr($tmp,5,1) =~ tr/-x/Ss/ if -g _; </td> </tr> <tr> <td class="h" > <a name="1123">1123</a> </td> <td class="c0" > <a href="#1124"> 0 </a> </td> <td class="c0" > <a href="blib-lib-CPAN-FTP-pm--branch.html#1123-1"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> substr($tmp,8,1) =~ tr/-x/Tt/ if -k _; </td> </tr> <tr> <td class="h" > <a name="1124">1124</a> </td> <td class="c0" > <a href="#1126"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> $perms .= $tmp; </td> </tr> <tr> <td class="h" > <a name="1125">1125</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="1126">1126</a> </td> <td class="c0" > <a href="#1127"> 0 </a> </td> <td >   </td> <td class="c0" > <a href="blib-lib-CPAN-FTP-pm--condition.html#1126-1"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> my $user = $user{$uid} || $uid; # too lazy to implement lookup </td> </tr> <tr> <td class="h" > <a name="1127">1127</a> </td> <td class="c0" > <a href="#1129"> 0 </a> </td> <td >   </td> <td class="c0" > <a href="blib-lib-CPAN-FTP-pm--condition.html#1127-1"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> my $group = $group{$gid} || $gid; </td> </tr> <tr> <td class="h" > <a name="1128">1128</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="1129">1129</a> </td> <td class="c0" > <a href="#1130"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> my($sec,$min,$hour,$mday,$mon,$year) = localtime($mtime); </td> </tr> <tr> <td class="h" > <a name="1130">1130</a> </td> <td class="c0" > <a href="#1131"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> my($timeyear); </td> </tr> <tr> <td class="h" > <a name="1131">1131</a> </td> <td class="c0" > <a href="#1132"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> my($moname) = $moname[$mon]; </td> </tr> <tr> <td class="h" > <a name="1132">1132</a> </td> <td class="c0" > <a href="#1133"> 0 </a> </td> <td class="c0" > <a href="blib-lib-CPAN-FTP-pm--branch.html#1132-1"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> if (-M _ > 365.25 / 2) { </td> </tr> <tr> <td class="h" > <a name="1133">1133</a> </td> <td class="c0" > <a href="#1136"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> $timeyear = $year + 1900; </td> </tr> <tr> <td class="h" > <a name="1134">1134</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="1135">1135</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> else { </td> </tr> <tr> <td class="h" > <a name="1136">1136</a> </td> <td class="c0" > <a href="#1139"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> $timeyear = sprintf("%02d:%02d", $hour, $min); </td> </tr> <tr> <td class="h" > <a name="1137">1137</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="1138">1138</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="1139">1139</a> </td> <td class="c0" > 0 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> sprintf "%5lu %4ld %-10s %2d %-8s %-8s %8s %s %2d %5s %s\n", </td> </tr> <tr> <td class="h" > <a name="1140">1140</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> $ino, </td> </tr> <tr> <td class="h" > <a name="1141">1141</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> $blocks, </td> </tr> <tr> <td class="h" > <a name="1142">1142</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> $perms, </td> </tr> <tr> <td class="h" > <a name="1143">1143</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> $nlink, </td> </tr> <tr> <td class="h" > <a name="1144">1144</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> $user, </td> </tr> <tr> <td class="h" > <a name="1145">1145</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> $group, </td> </tr> <tr> <td class="h" > <a name="1146">1146</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> $sizemm, </td> </tr> <tr> <td class="h" > <a name="1147">1147</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> $moname, </td> </tr> <tr> <td class="h" > <a name="1148">1148</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> $mday, </td> </tr> <tr> <td class="h" > <a name="1149">1149</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> $timeyear, </td> </tr> <tr> <td class="h" > <a name="1150">1150</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> $pname; </td> </tr> <tr> <td class="h" > <a name="1151">1151</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="1152">1152</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="1153">1153</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> 1; </td> </tr> </table> </body> </html>